From 22c0f6ae0dd7baf7c7a9cc39011c9e3210e34fb5 Mon Sep 17 00:00:00 2001
From: Daniel Teske <daniel.teske@nokia.com>
Date: Mon, 18 Jul 2011 17:23:26 +0200
Subject: [PATCH] QmlRunControlFactory: Cleaner canRun code

Fixed a bug where the case config->qtVersion == 0 was mishandled.

Change-Id: Ic11133bcfbe402e8f7a19b99b59161f8a913a2ab
Reviewed-on: http://codereview.qt.nokia.com/1779
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Christiaan Janssen <christiaan.janssen@nokia.com>
---
 .../qmlprojectruncontrol.cpp                  | 26 ++++++++++---------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp
index 07e31679f05..6bf422b0936 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp
+++ b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp
@@ -151,22 +151,24 @@ bool QmlProjectRunControlFactory::canRun(RunConfiguration *runConfiguration,
 {
     QmlProjectRunConfiguration *config =
         qobject_cast<QmlProjectRunConfiguration*>(runConfiguration);
+    if (!config)
+        return false;
     if (mode == ProjectExplorer::Constants::RUNMODE)
-        return config != 0 && !config->viewerPath().isEmpty();
-    else if (mode != Debugger::Constants::DEBUGMODE)
+        return !config->viewerPath().isEmpty();
+    if (mode != Debugger::Constants::DEBUGMODE)
         return false;
 
-    bool qmlDebugSupportInstalled =
-            Debugger::DebuggerPlugin::isActiveDebugLanguage(Debugger::QmlLanguage);
-
-    if (config && qmlDebugSupportInstalled) {
-        if (!(config->qtVersion() && config->qtVersion()->needsQmlDebuggingLibrary())
-                || !config->observerPath().isEmpty())
-            return true;
-        if (config->qtVersion() && QtSupport::QmlObserverTool::canBuild(config->qtVersion()))
-            return true;
-    }
+    if (!Debugger::DebuggerPlugin::isActiveDebugLanguage(Debugger::QmlLanguage))
+        return false;
 
+    if (!config->observerPath().isEmpty())
+        return true;
+    if (!config->qtVersion())
+        return false;
+    if (!config->qtVersion()->needsQmlDebuggingLibrary())
+        return true;
+    if (QtSupport::QmlObserverTool::canBuild(config->qtVersion()))
+        return true;
     return false;
 }
 
-- 
GitLab