1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Fix updater search paths on XP

Fixes #2807
This commit is contained in:
tux3 2016-01-17 16:27:22 +01:00
parent 0ea0918ce9
commit 59ac2e54e1
No known key found for this signature in database
GPG Key ID: 7E086DD661263264

View File

@ -28,6 +28,7 @@
#include <QMetaObject>
#include <QDebug>
#include <QSettings>
#include <QStandardPaths>
#include "update.h"
@ -202,8 +203,7 @@ QString Widget::getSettingsDirPath()
#ifdef Q_OS_WIN
wchar_t* path;
wchar_t pathOld[MAX_PATH];
bool isOld = false; // If true, we have to use pathOld and older Windows API.
bool isOld = false; // If true, we can't unelevate and just return the path for our current home
auto shell32H = LoadLibrary(TEXT("shell32.dll"));
if (!(isOld = (shell32H == nullptr)))
@ -213,15 +213,18 @@ QString Widget::getSettingsDirPath()
if (!(isOld = (SHGetKnownFolderPathH == nullptr)))
SHGetKnownFolderPathH(FOLDERID_RoamingAppData, 0, hPrimaryToken, &path);
}
if (isOld)
{
qDebug() << "Falling back to legacy APIs...";
SHGetFolderPathW(nullptr, CSIDL_APPDATA, nullptr, 0, pathOld);
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
+ "AppData" + QDir::separator() + "Roaming" + QDir::separator() + "tox" + QDir::separator());
}
else
{
QString pathStr = QString::fromStdWString(path);
pathStr.replace("\\", "/");
return pathStr + "/tox";
}
QString pathStr = QString::fromStdWString(isOld ? pathOld : path);
pathStr.replace("\\", "/");
return pathStr + "/tox";
#else
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QDir::separator() + "tox");
#endif