Page MenuHome GnuPG

No OneTemporary

diff --git a/patches/qtbase/0001-Gpg4win-qstandardpaths-patch.patch b/patches/qtbase/0001-Gpg4win-qstandardpaths-patch.patch
index 4718971a..c5ff63f1 100755
--- a/patches/qtbase/0001-Gpg4win-qstandardpaths-patch.patch
+++ b/patches/qtbase/0001-Gpg4win-qstandardpaths-patch.patch
@@ -1,131 +1,134 @@
#! /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,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 +635,73 @@ bool QStandardPaths::isTestModeEnabled()
+@@ -626,6 +635,76 @@ bool QStandardPaths::isTestModeEnabled()
return qsp_testMode;
}
+#if !defined(QT_BUILD_QMAKE) && !defined(QT_NO_SETTINGS) && !defined(QT_BOOTSTRAPPED)
++#ifdef Q_OS_WIN
++extern QString qAppFileName();
++#endif
+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());
++#ifdef Q_OS_WIN
++ // Note: QCoreApplication::applicationDirPath(), while static, requires
++ // an application instance. But we might need to resolve the standard
++ // locations earlier than that, so we fall back to qAppFileName().
++ const QString applicationDirPath = qApp ? QCoreApplication::applicationDirPath()
++ : QFileInfo(qAppFileName()).path();
++#else
++ const QString applicationDirPath = qApp ? QCoreApplication::applicationDirPath()
++ : QString();
++#endif
++ if (!applicationDirPath.isEmpty()) {
++ QDir pwd(applicationDirPath);
+ qtconfig = pwd.filePath(QLatin1String("qt.conf"));
+ if (QFile::exists(qtconfig))
+ return new QSettings(qtconfig, QSettings::IniFormat);
+ }
-+ return 0; //no luck
++ return nullptr; //no luck
+}
+#endif
+
+QString QStandardPaths::presetLocation(StandardLocation type)
+{
+#if !defined(QT_BUILD_QMAKE) && !defined(QT_NO_SETTINGS) && !defined(QT_BOOTSTRAPPED)
-+ // 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
-+ {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
-+ };
+ QScopedPointer<const QSettings> settings(findConfiguration());
++ if (settings.isNull())
++ return QString();
+
+ 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();
++ QString value = 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();
+ }
+ value = expanded;
+ } else {
+ OutputDebugString(L"QStandardPaths::presetLocation - Expanding environment variables in qt.conf failed.");
+ return QString();
+ }
+ }
+#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();
+ }
+ }
+ 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

Mime Type
text/x-diff
Expires
Sun, Dec 14, 10:43 AM (1 d, 13 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
65/f9/9d213bd63005b071038b7ec68e16

Event Timeline