From 7f38e17e7251921158f0a321f24167a0cec35d19 Mon Sep 17 00:00:00 2001
From: dt <qtc-committer@nokia.com>
Date: Tue, 17 Mar 2009 16:06:19 +0100
Subject: [PATCH] Fixes:    Custom Run Executable settings showing wrong errors

Task:     Found while testing the cmake plugin
Details:  Don't validate the working directoryl as it depends on the
magic $BUILDDIR variable, validate the executable as a command.
---
 src/libs/utils/pathchooser.h                  |  2 +-
 .../customexecutablerunconfiguration.cpp      | 19 ++++++++++++++++---
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/libs/utils/pathchooser.h b/src/libs/utils/pathchooser.h
index 92935b66fec..29352cd8744 100644
--- a/src/libs/utils/pathchooser.h
+++ b/src/libs/utils/pathchooser.h
@@ -77,7 +77,7 @@ public:
     // Returns the suggested label title when used in a form layout
     static QString label();
 
-    bool validatePath(const QString &path, QString *errorMessage = 0);
+    virtual bool validatePath(const QString &path, QString *errorMessage = 0);
 
     // Return the home directory, which needs some fixing under Windows.
     static QString homePath();
diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp
index 03eb8643e92..7aa185d7386 100644
--- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp
+++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp
@@ -43,6 +43,19 @@
 using namespace ProjectExplorer;
 using namespace ProjectExplorer::Internal;
 
+class CustomDirectoryPathChooser : public Core::Utils::PathChooser
+{
+public:
+    CustomDirectoryPathChooser(QWidget *parent)
+        : Core::Utils::PathChooser(parent)
+    {
+    }
+    virtual bool validatePath(const QString &path, QString *errorMessage = 0)
+    {
+        return true;
+    }
+};
+
 CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomExecutableRunConfiguration *rc)
     : m_ignoreChange(false)
 {
@@ -55,14 +68,15 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
     layout->addRow("Name:", m_userName);
 
     m_executableChooser = new Core::Utils::PathChooser(this);
-    m_executableChooser->setExpectedKind(Core::Utils::PathChooser::File);
+    m_executableChooser->setExpectedKind(Core::Utils::PathChooser::Command);
     layout->addRow("Executable:", m_executableChooser);
 
     m_commandLineArgumentsLineEdit = new QLineEdit(this);
     m_commandLineArgumentsLineEdit->setMinimumWidth(200); // this shouldn't be fixed here...
     layout->addRow("Arguments:", m_commandLineArgumentsLineEdit);
 
-    m_workingDirectory = new Core::Utils::PathChooser(this);
+    m_workingDirectory = new CustomDirectoryPathChooser(this);
+    m_workingDirectory->setExpectedKind(Core::Utils::PathChooser::Directory);
     layout->addRow("Working Directory:", m_workingDirectory);
 
     m_useTerminalCheck = new QCheckBox(tr("Run in &Terminal"), this);
@@ -71,7 +85,6 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
     setLayout(layout);
     changed();
     
-
     connect(m_userName, SIGNAL(textEdited(QString)),
             this, SLOT(setUserName(QString)));
     connect(m_executableChooser, SIGNAL(changed()),
-- 
GitLab