summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-07-26 08:22:45 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-07-26 21:05:17 (GMT)
commitfc2696f151f6e19ecb93589e88c7e64796a55faa (patch)
tree81affbc0760847b3186fee301cd4691091c27240 /demos
parentd27207366b6107bc3dff49d6c444f5f7420d65ff (diff)
downloadQt-fc2696f151f6e19ecb93589e88c7e64796a55faa.zip
Qt-fc2696f151f6e19ecb93589e88c7e64796a55faa.tar.gz
Qt-fc2696f151f6e19ecb93589e88c7e64796a55faa.tar.bz2
QtDemo: Find installed examples on Windows.
Add the '.exe' suffix before checking for the existence of the file in the example folder and the 'Debug'/'Release' subfolders. Clean up the code. Task-number: QTBUG-26531 Change-Id: Idd4927558573fe68bf12f98863d0c8848257d3e2 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
Diffstat (limited to 'demos')
-rw-r--r--demos/qtdemo/menumanager.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/demos/qtdemo/menumanager.cpp b/demos/qtdemo/menumanager.cpp
index 4c4440b..dd91ff4 100644
--- a/demos/qtdemo/menumanager.cpp
+++ b/demos/qtdemo/menumanager.cpp
@@ -518,16 +518,28 @@ QString MenuManager::resolveExeFile(const QString &name)
dir.cd(dirName);
dir.cd(fileName);
- fileName = fileName.split("/").last();
- QFile unixFile(dir.path() + "/" + fileName);
- if (unixFile.exists()) return unixFile.fileName();
- QFile winR(dir.path() + "\\release\\" + fileName + ".exe");
- if (winR.exists()) return winR.fileName();
- QFile winD(dir.path() + "\\debug\\" + fileName + ".exe");
- if (winD.exists()) return winD.fileName();
- QFile mac(dir.path() + "/" + fileName + ".app");
- if (mac.exists()) return mac.fileName();
-
+ fileName = fileName.split(QLatin1Char('/')).last();
+#ifdef Q_OS_WIN
+ fileName += QLatin1String(".exe");
+#endif
+ // UNIX, Mac non-framework and Windows installed builds.
+ const QFile installedFile(dir.path() + QLatin1Char('/') + fileName);
+ if (installedFile.exists())
+ return installedFile.fileName();
+ // Windows in-source builds
+#if defined(Q_OS_WIN)
+ const QFile winR(dir.path() + QLatin1String("/release/") + fileName);
+ if (winR.exists())
+ return winR.fileName();
+ const QFile winD(dir.path() + QLatin1String("/debug/") + fileName);
+ if (winD.exists())
+ return winD.fileName();
+#elif defined(Q_OS_MAC)
+ // Mac frameworks
+ const QFile mac(dir.path() + QLatin1Char('/') + fileName + QLatin1String(".app"));
+ if (mac.exists())
+ return mac.fileName();
+#endif
if (Colors::verbose)
qDebug() << "- WARNING: Could not resolve executable:" << dir.path() << fileName;
return "__executable not found__";