From fb8d52e6e0cdfec23bfc28df6f8270c027e2a923 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Fri, 16 Jul 2010 14:06:30 +0000 Subject: [PATCH] Safer registry usage on Win32 --- src/preferences.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/preferences.h b/src/preferences.h index f6e72a991..abae3f1d9 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -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;