Fix Qt Windows XP Support, hopefully.
authorAndre Heinecke <aheinecke@intevation.de>
Fri, 9 Jun 2017 14:40:24 +0000 (16:40 +0200)
committerAndre Heinecke <aheinecke@intevation.de>
Fri, 9 Jun 2017 14:40:24 +0000 (16:40 +0200)
* patches/qtbase/windowsxp-support.patch: New.
* Makfile.am (EXTRA_DIST): Add patch.

Makefile.am
patches/qtbase/windowsxp-support.patch [new file with mode: 0755]

index 224df93..989d96d 100644 (file)
@@ -32,6 +32,7 @@ EXTRA_DIST = autogen.sh README.GIT ONEWS \
         patches/qtbase/relative-paths.patch \
         patches/qtbase/qtbase-mingw-fixes.patch \
         patches/qtbase/config-standardpaths.patch \
+        patches/qtbase/windowsxp-support.patch \
         patches/qtwinextras/support-xp.patch \
         patches/w32pth-2.0.5/workaround-broken-libtool.patch \
         patches/qttools/disable-most-tools.patch \
diff --git a/patches/qtbase/windowsxp-support.patch b/patches/qtbase/windowsxp-support.patch
new file mode 100755 (executable)
index 0000000..cf853ad
--- /dev/null
@@ -0,0 +1,56 @@
+#! /bin/sh
+patch -p1 -f -l $* < $0
+exit $?
+
+diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
+index e12da68671..c9d2a4b80f 100644
+--- a/src/corelib/io/qsettings.cpp
++++ b/src/corelib/io/qsettings.cpp
+@@ -54,6 +54,8 @@
+ #include "qstandardpaths.h"
+ #include <qdatastream.h>
+
++#include <private/qsystemlibrary_p.h>
++
+ #ifndef QT_NO_TEXTCODEC
+ #  include "qtextcodec.h"
+ #endif
+@@ -951,15 +953,34 @@ void QConfFileSettingsPrivate::initAccess()
+ }
+
+ #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+-static QString windowsConfigPath(const KNOWNFOLDERID &type)
++static QString convertCharArray(const wchar_t *path)
++{
++    return QDir::fromNativeSeparators(QString::fromWCharArray(path));
++}
++
++// Convenience for SHGetKnownFolderPath().
++static QString sHGetKnownFolderPath(const GUID &clsid)
+ {
+     QString result;
++    typedef HRESULT (WINAPI *GetKnownFolderPath)(const GUID&, DWORD, HANDLE, LPWSTR*);
+
+-    PWSTR path = nullptr;
+-    if (SHGetKnownFolderPath(type, KF_FLAG_DONT_VERIFY, NULL, &path) == S_OK) {
+-        result = QString::fromWCharArray(path);
++    static const GetKnownFolderPath sHGetKnownFolderPath = // Vista onwards.
++        reinterpret_cast<GetKnownFolderPath>(QSystemLibrary::resolve(QLatin1String("shell32"), "SHGetKnownFolderPath"));
++
++    LPWSTR path;
++    if (Q_LIKELY(sHGetKnownFolderPath && SUCCEEDED(sHGetKnownFolderPath(clsid, KF_FLAG_DONT_VERIFY, 0, &path)))) {
++        result = convertCharArray(path);
+         CoTaskMemFree(path);
+     }
++    return result;
++}
++
++static QString windowsConfigPath(const KNOWNFOLDERID &type)
++{
++    QString result;
++
++    PWSTR path = nullptr;
++    result = sHGetKnownFolderPath(type);
+
+     if (result.isEmpty()) {
+         if (type == FOLDERID_ProgramData) {