From fd6e18584ad97fe994065778565797632444dad3 Mon Sep 17 00:00:00 2001
From: Erik Verbruggen <erik.verbruggen@nokia.com>
Date: Fri, 9 Oct 2009 10:37:19 +0200
Subject: [PATCH] Added fall-back for the QML viewer to first check if there is
 one bundled with Qt Creator.

---
 src/plugins/qmlprojectmanager/qmlproject.cpp | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp
index 3eba42cdcd4..4e891641d19 100644
--- a/src/plugins/qmlprojectmanager/qmlproject.cpp
+++ b/src/plugins/qmlprojectmanager/qmlproject.cpp
@@ -491,8 +491,19 @@ void QmlRunConfiguration::restore(const ProjectExplorer::PersistentSettingsReade
     m_qmlViewerArgs = reader.restoreValue(QLatin1String("qmlviewerargs")).toString();
     m_scriptFile = reader.restoreValue(QLatin1String("mainscript")).toString();
 
-    if (m_qmlViewer.isEmpty())
-        m_qmlViewer = Utils::SynchronousProcess::locateBinary(QLatin1String("qmlviewer"));
+    if (m_qmlViewer.isEmpty()) {
+        // first see if there is a bundled qmlviewer
+#ifdef Q_OS_WIN32
+        const QLatin1String qmlViewerExe("qmlviewer.exe");
+#else
+        const QLatin1String qmlViewerExe("qmlviewer");
+#endif
+        const QFileInfo info(QCoreApplication::applicationDirPath(), qmlViewerExe);
+        if (info.exists() && info.isExecutable())
+            m_qmlViewer = info.absoluteFilePath();
+        else // if not, then try to locate it elsewhere
+            m_qmlViewer = Utils::SynchronousProcess::locateBinary(QLatin1String("qmlviewer"));
+    }
 
     if (m_scriptFile.isEmpty())
         m_scriptFile = tr("<Current File>");
-- 
GitLab