mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-08 22:07:53 +00:00
Safer registry usage on Win32
This commit is contained in:
parent
80c42cae1a
commit
fb8d52e6e0
@ -1070,24 +1070,30 @@ public:
|
||||
static QString getPythonPath() {
|
||||
QSettings reg_python("HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore", QSettings::NativeFormat);
|
||||
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());
|
||||
versions = versions.filter(QRegExp("2\\..*"));
|
||||
versions.sort();
|
||||
while(!versions.empty()) {
|
||||
const QString version = versions.takeLast();
|
||||
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")) {
|
||||
qDebug("Found python.exe at %s", qPrintable(path));
|
||||
return path;
|
||||
}
|
||||
}
|
||||
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";
|
||||
}
|
||||
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 QString::null;
|
||||
|
Loading…
Reference in New Issue
Block a user