From 953be6fc0797864aa1cf2dc7557450235b25389e Mon Sep 17 00:00:00 2001
From: Tobias Hunger <tobias.hunger@nokia.com>
Date: Mon, 30 Aug 2010 15:10:05 +0200
Subject: [PATCH] Update Qt name when a qmake path is given

 * Update the Qt name when entering the path to qmake via the text edit.
   Behaviour matches what used to happen when selecting qmake via
   the file browser now.

Task-number: QTCREATORBUG-2145
---
 .../qt4projectmanager/qtoptionspage.cpp        | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/plugins/qt4projectmanager/qtoptionspage.cpp b/src/plugins/qt4projectmanager/qtoptionspage.cpp
index 113b5f7c1a3..d0e0b7d59f4 100644
--- a/src/plugins/qt4projectmanager/qtoptionspage.cpp
+++ b/src/plugins/qt4projectmanager/qtoptionspage.cpp
@@ -596,12 +596,6 @@ void QtOptionsPageWidget::onQtBrowsed()
         return;
 
     updateCurrentQMakeLocation();
-    if (m_ui->nameEdit->text().isEmpty() || m_ui->nameEdit->text() == m_specifyNameString) {
-        QString name = ProjectExplorer::DebuggingHelperLibrary::qtVersionForQMake(QDir::cleanPath(dir));
-        if (!name.isEmpty())
-            m_ui->nameEdit->setText(name);
-        updateCurrentQtName();
-    }
     updateState();
 }
 
@@ -676,9 +670,10 @@ void QtOptionsPageWidget::updateCurrentQMakeLocation()
     if (currentItemIndex < 0)
         return;
     QtVersion *version = m_versions.at(currentItemIndex).data();
-    if (version->qmakeCommand() == m_ui->qmakePath->path())
+    QFileInfo fi(m_ui->qmakePath->path());
+    if (!fi.exists() || !fi.isFile() || version->qmakeCommand() == fi.absoluteFilePath())
         return;
-    version->setQMakeCommand(m_ui->qmakePath->path());
+    version->setQMakeCommand(fi.absoluteFilePath());
     currentItem->setText(1, QDir::toNativeSeparators(version->qmakeCommand()));
     showEnvironmentPage(currentItem);
 
@@ -692,6 +687,13 @@ void QtOptionsPageWidget::updateCurrentQMakeLocation()
         m_ui->rebuildButton->setEnabled(false);
     }
     updateDebuggingHelperStateLabel(version);
+
+    if (m_ui->nameEdit->text().isEmpty() || m_ui->nameEdit->text() == m_specifyNameString) {
+        QString name = ProjectExplorer::DebuggingHelperLibrary::qtVersionForQMake(version->qmakeCommand());
+        if (!name.isEmpty())
+            m_ui->nameEdit->setText(name);
+        updateCurrentQtName();
+    }
 }
 
 void QtOptionsPageWidget::updateCurrentMingwDirectory()
-- 
GitLab