mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-24 05:25:37 +00:00
Safer registry usage on Win32
This commit is contained in:
parent
80c42cae1a
commit
fb8d52e6e0
@ -1070,24 +1070,30 @@ public:
|
|||||||
static QString getPythonPath() {
|
static QString getPythonPath() {
|
||||||
QSettings reg_python("HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore", QSettings::NativeFormat);
|
QSettings reg_python("HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore", QSettings::NativeFormat);
|
||||||
QStringList versions = reg_python.childGroups();
|
QStringList versions = reg_python.childGroups();
|
||||||
|
if(versions.isEmpty()) {
|
||||||
|
reg_python = QSettings("HKEY_LOCAL_MACHINE/SOFTWARE/Python/PythonCore", QSettings::NativeFormat);
|
||||||
|
versions = reg_python.childGroups();
|
||||||
|
}
|
||||||
qDebug("Python versions nb: %d", versions.size());
|
qDebug("Python versions nb: %d", versions.size());
|
||||||
versions = versions.filter(QRegExp("2\\..*"));
|
versions = versions.filter(QRegExp("2\\..*"));
|
||||||
versions.sort();
|
versions.sort();
|
||||||
while(!versions.empty()) {
|
while(!versions.empty()) {
|
||||||
const QString version = versions.takeLast();
|
const QString version = versions.takeLast();
|
||||||
qDebug("Detected possible Python v%s location", qPrintable(version));
|
qDebug("Detected possible Python v%s location", qPrintable(version));
|
||||||
QString path = reg_python.value(version+"/InstallPath/Default", "").toString().replace("/", "\\");
|
QString path = reg_python.value(version+"\\InstallPath\\Default", "").toString().replace("/", "\\");
|
||||||
|
if(path.isEmpty())
|
||||||
|
path = reg_python.value(version+"/InstallPath/Default", "").toString().replace("/", "\\");
|
||||||
if(!path.isEmpty() && QDir(path).exists("python.exe")) {
|
if(!path.isEmpty() && QDir(path).exists("python.exe")) {
|
||||||
qDebug("Found python.exe at %s", qPrintable(path));
|
qDebug("Found python.exe at %s", qPrintable(path));
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(QFile::exists("C:/Python26/python.exe")) {
|
if(QFile::exists("C:/Python26/python.exe")) {
|
||||||
reg_python.setValue("2.6/InstallPath/Default", "C:\\Python26");
|
reg_python.setValue("2.6\\InstallPath\\Default", "C:\\Python26");
|
||||||
return "C:\\Python26";
|
return "C:\\Python26";
|
||||||
}
|
}
|
||||||
if(QFile::exists("C:/Python25/python.exe")) {
|
if(QFile::exists("C:/Python25/python.exe")) {
|
||||||
reg_python.setValue("2.5/InstallPath/Default", "C:\\Python26");
|
reg_python.setValue("2.5\\InstallPath\\Default", "C:\\Python26");
|
||||||
return "C:\\Python25";
|
return "C:\\Python25";
|
||||||
}
|
}
|
||||||
return QString::null;
|
return QString::null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user