From e35a1e612a8817b3393967d7aea9e86564c210cc Mon Sep 17 00:00:00 2001
From: dt <qtc-committer@nokia.com>
Date: Tue, 9 Mar 2010 17:30:49 +0100
Subject: [PATCH] Fix crash for Custom Executable RunConfiguation with qml
 projects

Custom Executable RunConfiguation assumed that there is always a active
buildconfiguration which is simply not true for qml projects.

Also fix a small bug that the executable was not searched in the full
environment but only in the build environment.

Reviewed-By: Tobias Hunger
---
 .../customexecutablerunconfiguration.cpp             | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp
index 570d6fb4e4f..1d7dfbee5f7 100644
--- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp
+++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp
@@ -329,7 +329,7 @@ QString CustomExecutableRunConfiguration::executable() const
 {
     QString exec;
     if (!m_executable.isEmpty() && QDir::isRelativePath(m_executable)) {
-        Environment env = activeBuildConfiguration()->environment();
+        Environment env = environment();
         exec = env.searchInPath(m_executable);
         if (exec.isEmpty())
             exec = QDir::cleanPath(workingDirectory() + QLatin1Char('/') + m_executable);
@@ -380,8 +380,11 @@ QString CustomExecutableRunConfiguration::baseWorkingDirectory() const
 QString CustomExecutableRunConfiguration::workingDirectory() const
 {
     QString wd = m_workingDirectory;
-    QString bd = activeBuildConfiguration()->buildDirectory();
-    return wd.replace("$BUILDDIR", QDir::cleanPath(bd));
+    if (activeBuildConfiguration()) {
+        QString bd = activeBuildConfiguration()->buildDirectory();
+        wd.replace("$BUILDDIR", QDir::cleanPath(bd));
+    }
+    return wd;
 }
 
 QStringList CustomExecutableRunConfiguration::commandLineArguments() const
@@ -409,7 +412,8 @@ ProjectExplorer::Environment CustomExecutableRunConfiguration::baseEnvironment()
     } else  if (m_baseEnvironmentBase == CustomExecutableRunConfiguration::SystemEnvironmentBase) {
         env = ProjectExplorer::Environment::systemEnvironment();
     } else  if (m_baseEnvironmentBase == CustomExecutableRunConfiguration::BuildEnvironmentBase) {
-        env = activeBuildConfiguration()->environment();
+        if (activeBuildConfiguration())
+            env = activeBuildConfiguration()->environment();
     }
     return env;
 }
-- 
GitLab