From fc2696f151f6e19ecb93589e88c7e64796a55faa Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 26 Jul 2012 10:22:45 +0200 Subject: 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 Reviewed-by: Joerg Bornemann --- demos/qtdemo/menumanager.cpp | 32 ++++++++++++++++++++++---------- 1 file 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__"; -- cgit v0.12