Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F34113325
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
7 KB
Subscribers
None
View Options
diff --git a/patches/qtbase/0001-Gpg4win-qstandardpaths-patch.patch b/patches/qtbase/0001-Gpg4win-qstandardpaths-patch.patch
index 5f823259..4718971a 100755
--- a/patches/qtbase/0001-Gpg4win-qstandardpaths-patch.patch
+++ b/patches/qtbase/0001-Gpg4win-qstandardpaths-patch.patch
@@ -1,131 +1,131 @@
#! /bin/sh
patch -p1 -f -l $* < $0
exit $?
From ec9c327d811b4a7c489d42ae45d0fb69443ab30f Mon Sep 17 00:00:00 2001
From: Andre Heinecke <aheinecke@gnupg.org>
Date: Wed, 22 Jul 2020 13:17:21 +0200
Subject: [PATCH 1/2] Gpg4win-qstandardpaths-patch
---
src/corelib/io/qstandardpaths.cpp | 72 +++++++++++++++++++++++++++
src/corelib/io/qstandardpaths.h | 2 +
src/corelib/io/qstandardpaths_win.cpp | 4 +-
3 files changed, 77 insertions(+), 1 deletion(-)
--- a/src/corelib/io/qstandardpaths.cpp
+++ b/src/corelib/io/qstandardpaths.cpp
-@@ -20,6 +20,13 @@
+@@ -20,6 +20,15 @@
#include <unistd.h>
#endif
+#if !defined(QT_BUILD_QMAKE) && !defined(QT_NO_SETTINGS) && !defined(QT_BOOTSTRAPPED)
+#include <qsettings.h>
++#include <QMap>
++#include <QMetaEnum>
+#endif
+#ifdef Q_OS_WIN
+#include <windows.h>
+#endif
+
#ifndef QT_NO_STANDARDPATHS
QT_BEGIN_NAMESPACE
-@@ -626,6 +633,75 @@ bool QStandardPaths::isTestModeEnabled()
+@@ -626,6 +635,73 @@ bool QStandardPaths::isTestModeEnabled()
return qsp_testMode;
}
+#if !defined(QT_BUILD_QMAKE) && !defined(QT_NO_SETTINGS) && !defined(QT_BOOTSTRAPPED)
+static const char standardPathsSection[] = "StandardPaths";
+static QSettings *findConfiguration()
+{
+ QString qtconfig = QStringLiteral(":/qt/etc/qt.conf");
+ if (QFile::exists(qtconfig))
+ return new QSettings(qtconfig, QSettings::IniFormat);
+ if (QCoreApplication::instance()) {
+ QDir pwd(QCoreApplication::applicationDirPath());
+ qtconfig = pwd.filePath(QLatin1String("qt.conf"));
+ if (QFile::exists(qtconfig))
+ return new QSettings(qtconfig, QSettings::IniFormat);
+ }
+ return 0; //no luck
+}
+#endif
+
+QString QStandardPaths::presetLocation(StandardLocation type)
+{
+#if !defined(QT_BUILD_QMAKE) && !defined(QT_NO_SETTINGS) && !defined(QT_BOOTSTRAPPED)
-+ QStringList locations = QStringList() << QStringLiteral("DesktopLocation")
-+ << QStringLiteral("DocumentsLocation")
-+ << QStringLiteral("FontsLocation")
-+ << QStringLiteral("ApplicationsLocation")
-+ << QStringLiteral("MusicLocation")
-+ << QStringLiteral("MoviesLocation")
-+ << QStringLiteral("PicturesLocation")
-+ << QStringLiteral("TempLocation")
-+ << QStringLiteral("HomeLocation")
-+ << QStringLiteral("DataLocation")
-+ << QStringLiteral("CacheLocation")
-+ << QStringLiteral("GenericDataLocation")
-+ << QStringLiteral("RuntimeLocation")
-+ << QStringLiteral("ConfigLocation")
-+ << QStringLiteral("DownloadLocation")
-+ << QStringLiteral("GenericCacheLocation")
-+ << QStringLiteral("GenericConfigLocation")
-+ << QStringLiteral("AppDataLocation")
-+ << QStringLiteral("AppConfigLocation")
-+ << QStringLiteral("AppLocalDataLocation");
-+
-+ QScopedPointer<const QSettings> settings(findConfiguration());
-+ if (!settings.isNull()) {
-+ QString key = QLatin1String(standardPathsSection);
-+ key += QLatin1Char('/');
-+ key += locations[type];
-+ const QString value = settings->value(key).toString();
++ // hardcoded fallback for resolving standard paths before application has been created;
++ // keep in sync with qt.conf
++ static const QMap<QString, QString> fallback = {
+#ifdef Q_OS_WIN
-+ if (!value.contains(QLatin1Char('%')))
++ {QStringLiteral("StandardPaths/AppConfigLocation"), QStringLiteral("%APPDATA%/::APPNAME::")},
++ {QStringLiteral("StandardPaths/ConfigLocation"), QStringLiteral("%APPDATA%/::APPNAME::")},
++ {QStringLiteral("StandardPaths/GenericCacheLocation"), QStringLiteral("%LOCALAPPDATA%/::APPNAME::/cache")},
++ {QStringLiteral("StandardPaths/GenericConfigLocation"), QStringLiteral("%APPDATA%/::APPNAME::")},
++ {QStringLiteral("StandardPaths/GenericDataLocation"), QStringLiteral("%LOCALAPPDATA%/::APPNAME::")},
++ {QStringLiteral("StandardPaths/GenericStateLocation"), QStringLiteral("%LOCALAPPDATA%/::APPNAME::/State")},
+#endif
-+ return value;
++ };
++ QScopedPointer<const QSettings> settings(findConfiguration());
++
++ const QString key = QLatin1String(standardPathsSection) + QLatin1Char('/') + QString::fromLatin1(QMetaEnum::fromType<QStandardPaths::StandardLocation>().valueToKey(type));
++ QString value = settings.isNull() ? fallback.value(key) : settings->value(key).toString();
+#ifdef Q_OS_WIN
++ if (value.contains(QLatin1Char('%'))) {
+ wchar_t expandedPath[MAX_PATH] = {0};
+ if (ExpandEnvironmentStrings((wchar_t*)value.utf16(), expandedPath, MAX_PATH)) {
+ const auto expanded = QString::fromWCharArray(expandedPath).replace(QLatin1Char('\\'), QLatin1Char('/'));
+ if (expanded.contains(QLatin1Char('%'))) {
+ OutputDebugString(L"QStandardPaths::presetLocation - Not all environment variables in qt.conf could be expanded.");
+ return QString();
+ }
-+ return expanded;
++ value = expanded;
++ } else {
++ OutputDebugString(L"QStandardPaths::presetLocation - Expanding environment variables in qt.conf failed.");
++ return QString();
+ }
-+ OutputDebugString(L"QStandardPaths::presetLocation - Expanding environment variables in qt.conf failed.");
++ }
+#endif
++ if (value.contains(QLatin1String("::APPNAME::"), Qt::CaseInsensitive)) {
++ if (!QCoreApplication::applicationName().isEmpty()) {
++ value.replace(QLatin1String("::APPNAME::"), QCoreApplication::applicationName(), Qt::CaseInsensitive);
++ } else {
++ // Don't print warning because this happens before main() already and we want to avoid irrelevant warnings
++ //OutputDebugString(L"QStandardPaths::presetLocation - Replacing ::APPNAME:: not possible before application name is set.");
++ return QString();
++ }
+ }
-+#endif // !QT_BUILD_QMAKE && !QT_NO_SETTINGS
-+
++ return value;
++#else
+ return QString();
++#endif // !QT_BUILD_QMAKE && !QT_NO_SETTINGS
+}
+
QT_END_NAMESPACE
--- a/src/corelib/io/qstandardpaths.h
+++ b/src/corelib/io/qstandardpaths.h
@@ -66,6 +66,8 @@
static bool isTestModeEnabled();
private:
+ static QString presetLocation(StandardLocation type);
+
// prevent construction
QStandardPaths();
~QStandardPaths();
--- a/src/corelib/io/qstandardpaths_win.cpp
+++ b/src/corelib/io/qstandardpaths_win.cpp
@@ -157,7 +157,9 @@
QString QStandardPaths::writableLocation(StandardLocation type)
{
- QString result;
+ QString result = QStandardPaths::presetLocation(type);
+ if (!result.isEmpty())
+ return result;
switch (type) {
case CacheLocation:
// Although Microsoft has a Cache key it is a pointer to IE's cache, not a cache
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Dec 5, 5:10 PM (18 m, 36 s)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
1a/cc/fe54be1a3c8e9028f12c9c820ec9
Attached To
rW Gpg4win
Event Timeline
Log In to Comment