From 2841e875b4cc99cf8772256dc4ca2c8852d14e7b Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Date: Fri, 7 Aug 2009 14:20:27 +0200
Subject: [PATCH] Revert "Debugger:  Improve the helper build mechanism on the
 settings page."

This reverts commit debb3961c2aaaf9104d6b19b4fc92e16b7c4da0c.
Success cannot be properly detected.
---
 .../projectexplorer/debugginghelper.cpp       | 160 +++++++---------
 src/plugins/projectexplorer/debugginghelper.h |   4 +-
 .../qt4projectmanager/qtoptionspage.cpp       | 173 +++++-------------
 src/plugins/qt4projectmanager/qtoptionspage.h |  33 +---
 .../qt4projectmanager/qtversionmanager.cpp    |   6 +-
 .../qt4projectmanager/qtversionmanager.ui     | 162 ++++++++--------
 6 files changed, 198 insertions(+), 340 deletions(-)

diff --git a/src/plugins/projectexplorer/debugginghelper.cpp b/src/plugins/projectexplorer/debugginghelper.cpp
index eac74ef2c96..8af5ba30456 100644
--- a/src/plugins/projectexplorer/debugginghelper.cpp
+++ b/src/plugins/projectexplorer/debugginghelper.cpp
@@ -28,15 +28,13 @@
 **************************************************************************/
 
 #include "debugginghelper.h"
-
 #include <coreplugin/icore.h>
 #include <QtCore/QFileInfo>
-#include <QtCore/QCoreApplication>
 #include <QtCore/QHash>
 #include <QtCore/QProcess>
 #include <QtCore/QDir>
 #include <QtCore/QDateTime>
-
+#include <QtGui/QApplication>
 #include <QtGui/QDesktopServices>
 
 using namespace ProjectExplorer;
@@ -46,7 +44,7 @@ QString DebuggingHelperLibrary::findSystemQt(const Environment &env)
     QStringList paths = env.path();
     foreach (const QString &path, paths) {
         foreach (const QString &possibleCommand, possibleQMakeCommands()) {
-            const QFileInfo qmake(path + QLatin1Char('/') + possibleCommand);
+            QFileInfo qmake(path + "/" + possibleCommand);
             if (qmake.exists()) {
                 if (!qtVersionForQMake(qmake.absoluteFilePath()).isNull()) {
                     return qmake.absoluteFilePath();
@@ -64,13 +62,12 @@ bool DebuggingHelperLibrary::hasDebuggingHelperLibrary(const QString &qmakePath)
 
 QStringList DebuggingHelperLibrary::debuggingHelperLibraryDirectories(const QString &qtInstallData, const QString &qtpath)
 {
-    const QChar slash = QLatin1Char('/');
-    const uint hash = qHash(qtpath);
+    uint hash = qHash(qtpath);
     QStringList directories;
     directories
-            << (qtInstallData + QLatin1String("/qtc-debugging-helper/"))
-            << QDir::cleanPath((QCoreApplication::applicationDirPath() + QLatin1String("/../qtc-debugging-helper/") + QString::number(hash))) + slash
-            << (QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QLatin1String("/qtc-debugging-helper/") + QString::number(hash)) + slash;
+            << (qtInstallData + "/qtc-debugging-helper/")
+            << QDir::cleanPath((QApplication::applicationDirPath() + "/../qtc-debugging-helper/" + QString::number(hash))) + "/"
+            << (QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/qtc-debugging-helper/" + QString::number(hash)) + "/";
     return directories;
 }
 
@@ -87,7 +84,7 @@ QString DebuggingHelperLibrary::debuggingHelperLibrary(const QString &qmakePath)
 QString DebuggingHelperLibrary::qtInstallDataDir(const QString &qmakePath)
 {
     QProcess proc;
-    proc.start(qmakePath, QStringList() << QLatin1String("-query") << QLatin1String("QT_INSTALL_DATA"));
+    proc.start(qmakePath, QStringList() << "-query"<< "QT_INSTALL_DATA");
     if (proc.waitForFinished())
         return QString(proc.readAll().trimmed());
     return QString::null;
@@ -102,142 +99,119 @@ QString DebuggingHelperLibrary::qtDir(const QString &qmakePath)
 
 // Debugging Helper Library
 
-static inline QString helperFilePath(const QString &directory)
+QStringList DebuggingHelperLibrary::debuggingHelperLibraryLocations(const QString &qtInstallData, const QString &qtpath)
 {
+    QStringList result;
+    foreach(const QString &directory, debuggingHelperLibraryDirectories(qtInstallData, qtpath)) {
 #if defined(Q_OS_WIN)
-    return directory + QLatin1String("debug/gdbmacros.dll");
+        QFileInfo fi(directory + "debug/gdbmacros.dll");
 #elif defined(Q_OS_MAC)
-    return directory + QLatin1String("libgdbmacros.dylib");
+        QFileInfo fi(directory + "libgdbmacros.dylib");
 #else // generic UNIX
-    return directory + QLatin1String("libgdbmacros.so");
+        QFileInfo fi(directory + "libgdbmacros.so");
 #endif
-}
-
-QStringList DebuggingHelperLibrary::debuggingHelperLibraryLocations(const QString &qtInstallData, const QString &qtpath)
-{
-    QStringList result;
-    foreach(const QString &directory, debuggingHelperLibraryDirectories(qtInstallData, qtpath))
-        result << QFileInfo(helperFilePath(directory)).filePath();
+        result << fi.filePath();
+    }
     return result;
 }
 
 QString DebuggingHelperLibrary::debuggingHelperLibrary(const QString &qtInstallData, const QString &qtpath)
 {
     foreach(const QString &directory, debuggingHelperLibraryDirectories(qtInstallData, qtpath)) {
-        const QFileInfo fi(helperFilePath(directory));
+#if defined(Q_OS_WIN)
+        QFileInfo fi(directory + "debug/gdbmacros.dll");
+#elif defined(Q_OS_MAC)
+        QFileInfo fi(directory + "libgdbmacros.dylib");
+#else // generic UNIX
+        QFileInfo fi(directory + "libgdbmacros.so");
+#endif
         if (fi.exists())
             return fi.filePath();
     }
     return QString();
 }
 
+
 QString DebuggingHelperLibrary::buildDebuggingHelperLibrary(const QString &qmakePath, const QString &make, const Environment &env)
 {
-    QString errorMessage;
-    const QString directory = copyDebuggingHelperLibrary(qtInstallDataDir(qmakePath), qtDir(qmakePath), &errorMessage);
+    QString directory = copyDebuggingHelperLibrary(qtInstallDataDir(qmakePath), qtDir(qmakePath));
     if (directory.isEmpty())
-        return errorMessage;
+        return QString::null;
     return buildDebuggingHelperLibrary(directory, make, qmakePath, QString::null, env);
 }
 
-// Copy helper source files to a target directory, replacing older files.
-static bool copyDebuggingHelperFiles(const QStringList &files,
-                                     const QString &targetDirectory,
-                                     QString *errorMessage)
-{
-    const QString dumperSourcePath = Core::ICore::instance()->resourcePath() + QLatin1String("/gdbmacros/");
-    if (!QDir().mkpath(targetDirectory)) {
-        *errorMessage = QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary", "The target directory %1 could not be created.").arg(targetDirectory);
-        return false;
-    }
-    foreach (const QString &file, files) {
-        const QString source = dumperSourcePath + file;
-        const QString dest = targetDirectory + file;
-        const QFileInfo destInfo(dest);
-        if (destInfo.exists()) {
-            if (destInfo.lastModified() >= QFileInfo(source).lastModified())
-                continue;
-            if (!QFile::remove(dest)) {
-                *errorMessage = QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary", "The existing file %1 could not be removed.").arg(destInfo.absoluteFilePath());
-                return false;
-            }
-        }
-        if (!QFile::copy(source, dest)) {
-            *errorMessage = QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary", "The file %1 could not be copied to %2.").arg(source, dest);
-            return false;
-        }
-    }
-    return true;
-}
-
-QString DebuggingHelperLibrary::copyDebuggingHelperLibrary(const QString &qtInstallData,
-                                                           const QString &qtdir,
-                                                           QString *errorMessage)
+QString DebuggingHelperLibrary::copyDebuggingHelperLibrary(const QString &qtInstallData, const QString &qtdir)
 {
     // Locations to try:
     //    $QTDIR/qtc-debugging-helper
     //    $APPLICATION-DIR/qtc-debugging-helper/$hash
     //    $USERDIR/qtc-debugging-helper/$hash
-    const QStringList directories = DebuggingHelperLibrary::debuggingHelperLibraryDirectories(qtInstallData, qtdir);
+    QStringList directories = DebuggingHelperLibrary::debuggingHelperLibraryDirectories(qtInstallData, qtdir);
 
     QStringList files;
-    files << QLatin1String("gdbmacros.cpp") << QLatin1String("gdbmacros.pro")
-          << QLatin1String("LICENSE.LGPL") << QLatin1String("LGPL_EXCEPTION.TXT");
-    // Try to find a writeable directory.
-    foreach(const QString &directory, directories)
-        if (copyDebuggingHelperFiles(files, directory, errorMessage)) {
-            errorMessage->clear();
-            return directory;
+    files << "gdbmacros.cpp" << "gdbmacros.pro"
+          << "LICENSE.LGPL" << "LGPL_EXCEPTION.TXT";
+    foreach(const QString &directory, directories) {
+        QString dumperPath = Core::ICore::instance()->resourcePath() + "/gdbmacros/";
+        bool success = true;
+        QDir().mkpath(directory);
+        foreach (const QString &file, files) {
+            QString source = dumperPath + file;
+            QString dest = directory + file;
+            QFileInfo destInfo(dest);
+            if (destInfo.exists()) {
+                if (destInfo.lastModified() >= QFileInfo(source).lastModified())
+                    continue;
+                success &= QFile::remove(dest);
+            }
+            success &= QFile::copy(source, dest);
         }
-    *errorMessage = QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary", "The debugger helpers could not be built in any of the directories:\n- %1\n\nReason: %2")
-                    .arg(directories.join(QLatin1String("\n- ")), *errorMessage);
-    return QString();
+        if (success)
+            return directory;
+    }
+    return QString::null;
 }
 
 QString DebuggingHelperLibrary::buildDebuggingHelperLibrary(const QString &directory, const QString &makeCommand, const QString &qmakeCommand, const QString &mkspec, const Environment &env)
 {
     QString output;
-    const QChar newline = QLatin1Char('\n');
     // Setup process
     QProcess proc;
     proc.setEnvironment(env.toStringList());
     proc.setWorkingDirectory(directory);
     proc.setProcessChannelMode(QProcess::MergedChannels);
 
-    output += QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary", "Building debugging helper library in %1\n").arg(directory);
-    output += newline;
+    output += QString("Building debugging helper library in %1\n").arg(directory);
+    output += "\n";
 
-    const QString makeFullPath = env.searchInPath(makeCommand);
-    if (QFileInfo(directory + QLatin1String("/Makefile")).exists()) {
+    QString makeFullPath = env.searchInPath(makeCommand);
+    if (QFileInfo(directory + "/Makefile").exists()) {
         if (!makeFullPath.isEmpty()) {
-            const QString cleanTarget = QLatin1String("distclean");
-            output += QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary", "Running %1 %2...\n").arg(makeFullPath, cleanTarget);
-            proc.start(makeFullPath, QStringList(cleanTarget));
+            output += QString("Running %1 clean...\n").arg(makeFullPath);
+            proc.start(makeFullPath, QStringList() << "clean");
             proc.waitForFinished();
-            output += QString::fromLocal8Bit(proc.readAll());
+            output += proc.readAll();
         } else {
-            output += QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary", "%1 not found in PATH\n").arg(makeCommand);
+            output += QString("%1 not found in PATH\n").arg(makeCommand);
             return output;
         }
     }
-    output += newline;
-    output += QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary", "Running %1 ...\n").arg(qmakeCommand);
 
-    QStringList makeArgs;
-    makeArgs << QLatin1String("-spec")<< (mkspec.isEmpty() ? QString(QLatin1String("default")) : mkspec) << QLatin1String("gdbmacros.pro");
-    proc.start(qmakeCommand, makeArgs);
+    output += QString("\nRunning %1 ...\n").arg(qmakeCommand);
+
+    proc.start(qmakeCommand, QStringList()<<"-spec"<< (mkspec.isEmpty() ? "default" : mkspec) <<"gdbmacros.pro");
     proc.waitForFinished();
 
     output += proc.readAll();
 
-    output += newline;;
+    output += "\n";
     if (!makeFullPath.isEmpty()) {
-        output += QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary", "Running %1 ...\n").arg(makeFullPath);
+        output += QString("Running %1 ...\n").arg(makeFullPath);
         proc.start(makeFullPath, QStringList());
         proc.waitForFinished();
         output += proc.readAll();
     } else {
-        output += QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary", "%1 not found in PATH\n").arg(makeCommand);
+        output += QString("%1 not found in PATH\n").arg(makeCommand);
     }
     return output;
 }
@@ -245,14 +219,14 @@ QString DebuggingHelperLibrary::buildDebuggingHelperLibrary(const QString &direc
 QString DebuggingHelperLibrary::qtVersionForQMake(const QString &qmakePath)
 {
     QProcess qmake;
-    qmake.start(qmakePath, QStringList(QLatin1String("--version")));
+    qmake.start(qmakePath, QStringList()<<"--version");
     if (!qmake.waitForFinished())
         return false;
     QString output = qmake.readAllStandardOutput();
-    QRegExp regexp(QLatin1String("(QMake version|QMake version:)[\\s]*([\\d.]*)"), Qt::CaseInsensitive);
+    QRegExp regexp("(QMake version|QMake version:)[\\s]*([\\d.]*)", Qt::CaseInsensitive);
     regexp.indexIn(output);
-    if (regexp.cap(2).startsWith(QLatin1String("2."))) {
-        QRegExp regexp2(QLatin1String("Using Qt version[\\s]*([\\d\\.]*)"), Qt::CaseInsensitive);
+    if (regexp.cap(2).startsWith("2.")) {
+        QRegExp regexp2("Using Qt version[\\s]*([\\d\\.]*)", Qt::CaseInsensitive);
         regexp2.indexIn(output);
         return regexp2.cap(1);
     }
@@ -263,11 +237,11 @@ QStringList DebuggingHelperLibrary::possibleQMakeCommands()
 {
     // On windows noone has renamed qmake, right?
 #ifdef Q_OS_WIN
-    return QStringList(QLatin1String("qmake.exe"));
+    return QStringList() << "qmake.exe";
 #else
     // On unix some distributions renamed qmake to avoid clashes
     QStringList result;
-    result << QLatin1String("qmake-qt4") << QLatin1String("qmake4") << QLatin1String("qmake");
+    result << "qmake-qt4" << "qmake4" << "qmake";
     return result;
 #endif
 }
diff --git a/src/plugins/projectexplorer/debugginghelper.h b/src/plugins/projectexplorer/debugginghelper.h
index 47727d1c466..a98ab2a6166 100644
--- a/src/plugins/projectexplorer/debugginghelper.h
+++ b/src/plugins/projectexplorer/debugginghelper.h
@@ -56,12 +56,10 @@ public:
     static QString buildDebuggingHelperLibrary(const QString &qmakePath, const QString &make, const Environment &env);
     static QString buildDebuggingHelperLibrary(const QString &directory, const QString &makeCommand, const QString &qmakeCommand, const QString &mkspec, const Environment &env);
 
-    // Build the helpers and return the output log/errormessage.
     static QStringList debuggingHelperLibraryLocations(const QString &qmakePath);
     static QStringList debuggingHelperLibraryLocations(const QString &qtInstallData, const QString &qtpath);
 
-    // Copy the source files to a target location and return the chosen target location.
-    static QString copyDebuggingHelperLibrary(const QString &qtInstallData, const QString &qtdir, QString *errorMessage);
+    static QString copyDebuggingHelperLibrary(const QString &qtInstallData, const QString &qtdir);
 
 private:
     static QStringList debuggingHelperLibraryDirectories(const QString &qtInstallData, const QString &qtpath);
diff --git a/src/plugins/qt4projectmanager/qtoptionspage.cpp b/src/plugins/qt4projectmanager/qtoptionspage.cpp
index 2f3721c324a..6c5c4c4a9cc 100644
--- a/src/plugins/qt4projectmanager/qtoptionspage.cpp
+++ b/src/plugins/qt4projectmanager/qtoptionspage.cpp
@@ -3,43 +3,14 @@
 #include "ui_qtversionmanager.h"
 #include "qt4projectmanagerconstants.h"
 #include "qtversionmanager.h"
-
 #include <coreplugin/coreconstants.h>
-#include <coreplugin/icore.h>
-#include <coreplugin/progressmanager/progressmanager.h>
 #include <utils/treewidgetcolumnstretcher.h>
-#include <utils/qtcassert.h>
 
-#include <QtCore/QFuture>
-#include <QtCore/QtConcurrentRun>
 #include <QtCore/QDebug>
 #include <QtCore/QDir>
-#include <QtCore/QDateTime>
 
 using namespace Qt4ProjectManager;
 using namespace Qt4ProjectManager::Internal;
-
-///
-// DebuggingHelperBuildTask
-///
-
-DebuggingHelperBuildTask::DebuggingHelperBuildTask(const QtVersion &version) :
-    m_version(new QtVersion(version))
-{
-}
-
-DebuggingHelperBuildTask::~DebuggingHelperBuildTask()
-{
-    delete m_version;
-}
-
-void DebuggingHelperBuildTask::run()
-{
-    const QString output = m_version->buildDebuggingHelperLibrary();
-    emit finished(m_version->name(), output);
-    deleteLater();
-}
-
 ///
 // QtOptionsPage
 ///
@@ -94,11 +65,6 @@ void QtOptionsPage::apply()
 
 QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> versions, QtVersion *defaultVersion)
     : QWidget(parent)
-    , m_debuggingHelperOkPixmap(QLatin1String(":/extensionsystem/images/ok.png"))
-    , m_debuggingHelperErrorPixmap(QLatin1String(":/extensionsystem/images/error.png"))
-    , m_debuggingHelperOkIcon(m_debuggingHelperOkPixmap)
-    , m_debuggingHelperErrorIcon(m_debuggingHelperErrorPixmap)
-
     , m_defaultVersion(versions.indexOf(defaultVersion))
     , m_specifyNameString(tr("<specify a name>"))
     , m_specifyPathString(tr("<specify a path>"))
@@ -140,7 +106,10 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver
         item->setData(0, Qt::UserRole, version->uniqueId());
 
         if (version->isValid()) {
-            item->setData(2, Qt::DecorationRole, version->hasDebuggingHelper() ? m_debuggingHelperOkIcon : m_debuggingHelperErrorIcon);
+            if (version->hasDebuggingHelper())
+                item->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/ok.png"));
+            else
+                item->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/error.png"));
         } else {
             item->setData(2, Qt::DecorationRole, QIcon());
         }
@@ -191,62 +160,27 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver
     updateState();
 }
 
-QtVersion *QtOptionsPageWidget::currentVersion() const
+void QtOptionsPageWidget::buildDebuggingHelper()
 {
-    if (QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem()) {
-        const int currentItemIndex = indexForTreeItem(currentItem);
-        if (currentItemIndex >= 0 && currentItemIndex < m_versions.size())
-            return m_versions.at(currentItemIndex);
-    }
-    return 0;
-}
+    // Find the qt version for this button..
+    QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem();
+    int currentItemIndex = indexForTreeItem(currentItem);
+    if (currentItemIndex < 0)
+        return;
 
-static inline int findVersionByName(const QList<QtVersion *> &l, const QString &name)
-{
-    const int size = l.size();
-    for (int i = 0; i < size; i++)
-        if (l.at(i)->name() == name)
-            return i;
-    return -1;
-}
+    QtVersion *version = m_versions[currentItemIndex];
 
-// Update with results of terminated helper build
-void QtOptionsPageWidget::debuggingHelperBuildFinished(const QString &name, const QString &output)
-{
-    const int index = findVersionByName(m_versions, name);
-    if (index == -1)
-        return; // Oops, somebody managed to delete the version
-    // Update item view
-    QtVersion *version = m_versions.at(index);
-    QTreeWidgetItem *item = treeItemForIndex(index);
-    QTC_ASSERT(item, return)            
-    item->setData(2, Qt::UserRole, output);
-    const bool success = version->hasDebuggingHelper();
-    item->setData(2, Qt::DecorationRole, success ? m_debuggingHelperOkIcon : m_debuggingHelperErrorIcon);
-
-    // Update bottom control if the selection is still the same
-    if (version == currentVersion()) {
-        m_ui->showLogButton->setEnabled(true);
-        updateDebuggingHelperStateLabel(version);
-        if (!success)
-            showDebuggingBuildLog();
-    }
-}
+    QString result = m_versions.at(currentItemIndex)->buildDebuggingHelperLibrary();
+    currentItem->setData(2, Qt::UserRole, result);
 
-void QtOptionsPageWidget::buildDebuggingHelper()
-{
-    if (QtVersion *version = currentVersion()) {
-        m_ui->showLogButton->setEnabled(false);
-        // Run a debugging helper build task in the background.
-        DebuggingHelperBuildTask *buildTask = new DebuggingHelperBuildTask(*version);
-        connect(buildTask, SIGNAL(finished(QString,QString)), this, SLOT(debuggingHelperBuildFinished(QString,QString)),
-                Qt::QueuedConnection);
-        QFuture<void> task = QtConcurrent::run(buildTask, &DebuggingHelperBuildTask::run);
-        const QString taskName = tr("Building helpers");
-        Core::ICore::instance()->progressManager()->addTask(task, taskName,
-                                                            QLatin1String("Qt4ProjectManager::BuildHelpers"),
-                                                            Core::ProgressManager::CloseOnSuccess);
+    if (version->hasDebuggingHelper()) {
+        m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/ok.png"));
+        currentItem->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/ok.png"));
+    } else {
+        m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/error.png"));
+        currentItem->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/error.png"));
     }
+    m_ui->showLogButton->setEnabled(true);
 }
 
 void QtOptionsPageWidget::showDebuggingBuildLog()
@@ -256,13 +190,10 @@ void QtOptionsPageWidget::showDebuggingBuildLog()
     int currentItemIndex = indexForTreeItem(currentItem);
     if (currentItemIndex < 0)
         return;
-    // Show text and scroll to bottom
     QDialog dlg;
     Ui_ShowBuildLog ui;
     ui.setupUi(&dlg);
     ui.log->setPlainText(currentItem->data(2, Qt::UserRole).toString());
-    ui.log->moveCursor(QTextCursor::End);
-    ui.log->ensureCursorVisible();
     dlg.exec();
 }
 
@@ -312,41 +243,12 @@ void QtOptionsPageWidget::removeQtDir()
     updateState();
 }
 
-// Format html table tooltip about helpers
-static inline QString msgHtmlHelperToolTip(const QFileInfo &fi)
-{
-    return QtOptionsPageWidget::tr("<html><body><table><tr><td>File:</td><td><pre>%1</pre></td></tr>"
-                                   "<tr><td>Last&nbsp;modified:</td><td>%2</td></tr>"
-                                   "<tr><td>Size:</td><td>%3 Bytes</td></tr></table></body></html>").
-                      arg(fi.absoluteFilePath()).
-                      arg(fi.lastModified().toString(Qt::SystemLocaleLongDate)).
-                      arg(fi.size());
-}
-
-// Update the state label with a pixmap and set a tooltip describing
-// the file on neighbouring controls.
-void QtOptionsPageWidget::updateDebuggingHelperStateLabel(const QtVersion *version)
-{
-    QString tooltip;
-    if (version && version->isValid()) {
-        const bool hasHelper = version->hasDebuggingHelper();
-        m_ui->debuggingHelperStateLabel->setPixmap(hasHelper ? m_debuggingHelperOkPixmap : m_debuggingHelperErrorPixmap);
-        if (hasHelper)
-            tooltip = msgHtmlHelperToolTip(QFileInfo(version->debuggingHelperLibrary()));
-    } else {
-        m_ui->debuggingHelperStateLabel->setPixmap(QPixmap());
-    }
-    m_ui->debuggingHelperStateLabel->setToolTip(tooltip);
-    m_ui->debuggingHelperLabel->setToolTip(tooltip);
-    m_ui->showLogButton->setToolTip(tooltip);
-    m_ui->rebuildButton->setToolTip(tooltip);
-}
-
 void QtOptionsPageWidget::updateState()
 {
-    const QtVersion *version  = currentVersion();
-    const bool enabled = version != 0;
-    const bool isAutodetected = enabled && version->isAutodetected();
+    int currentIndex = indexForTreeItem(m_ui->qtdirList->currentItem());
+    bool enabled = (currentIndex >= 0);
+    bool isAutodetected = (enabled
+        && m_versions.at(currentIndex)->isAutodetected());
     m_ui->delButton->setEnabled(enabled && !isAutodetected);
     m_ui->nameEdit->setEnabled(enabled && !isAutodetected);
     m_ui->qtPath->setEnabled(enabled && !isAutodetected);
@@ -355,9 +257,15 @@ void QtOptionsPageWidget::updateState()
     bool hasLog = enabled && !m_ui->qtdirList->currentItem()->data(2, Qt::UserRole).toString().isEmpty();
     m_ui->showLogButton->setEnabled(hasLog);
 
+    QtVersion *version = 0;
+    if (enabled)
+        version = m_versions.at(currentIndex);
     if (version) {
         m_ui->rebuildButton->setEnabled(version->isValid());
-        updateDebuggingHelperStateLabel(version);
+        if (version->hasDebuggingHelper())
+            m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/ok.png"));
+        else
+            m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/error.png"));
     } else {
         m_ui->rebuildButton->setEnabled(false);
         m_ui->debuggingHelperStateLabel->setPixmap(QPixmap());
@@ -450,11 +358,11 @@ void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item)
     }
 }
 
-int QtOptionsPageWidget::indexForTreeItem(const QTreeWidgetItem *item) const
+int QtOptionsPageWidget::indexForTreeItem(QTreeWidgetItem *item) const
 {
     if (!item || !item->parent())
         return -1;
-    const int uniqueId = item->data(0, Qt::UserRole).toInt();
+    int uniqueId = item->data(0, Qt::UserRole).toInt();
     for (int index = 0; index < m_versions.size(); ++index) {
         if (m_versions.at(index)->uniqueId() == uniqueId)
             return index;
@@ -599,10 +507,16 @@ void QtOptionsPageWidget::updateCurrentQtPath()
 
     showEnvironmentPage(currentItem);
 
-    const QtVersion *version = m_versions.at(currentItemIndex);
-    if (version->isValid()) {
-        const bool hasLog = !currentItem->data(2, Qt::UserRole).toString().isEmpty();
-        currentItem->setData(2, Qt::DecorationRole, version->hasDebuggingHelper() ? m_debuggingHelperOkIcon : m_debuggingHelperErrorIcon);
+    if (m_versions[currentItemIndex]->isValid()) {
+        bool hasLog = !currentItem->data(2, Qt::UserRole).toString().isEmpty();
+        bool hasHelper = m_versions[currentItemIndex]->hasDebuggingHelper();
+        if (hasHelper) {
+            currentItem->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/ok.png"));
+            m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/ok.png"));
+        } else {
+            currentItem->setData(2, Qt::DecorationRole, QIcon(":/extensionsystem/images/error.png"));
+            m_ui->debuggingHelperStateLabel->setPixmap(QPixmap(":/extensionsystem/images/error.png"));
+        }
         m_ui->showLogButton->setEnabled(hasLog);
         m_ui->rebuildButton->setEnabled(true);
     } else {
@@ -610,7 +524,6 @@ void QtOptionsPageWidget::updateCurrentQtPath()
         m_ui->debuggingHelperStateLabel->setPixmap(QPixmap());
         m_ui->rebuildButton->setEnabled(true);
     }
-    updateDebuggingHelperStateLabel(version);
 }
 
 void QtOptionsPageWidget::updateCurrentMingwDirectory()
diff --git a/src/plugins/qt4projectmanager/qtoptionspage.h b/src/plugins/qt4projectmanager/qtoptionspage.h
index dc2bb3a9465..57275795fe6 100644
--- a/src/plugins/qt4projectmanager/qtoptionspage.h
+++ b/src/plugins/qt4projectmanager/qtoptionspage.h
@@ -32,8 +32,6 @@
 #include <coreplugin/dialogs/ioptionspage.h>
 
 #include <QtGui/QWidget>
-#include <QtGui/QPixmap>
-#include <QtGui/QIcon>
 
 QT_BEGIN_NAMESPACE
 class QTreeWidgetItem;
@@ -48,24 +46,6 @@ namespace Ui {
 class QtVersionManager;
 }
 
-// A task suitable to be run by QtConcurrent to build the helpers.
-// It may outlive the settings page if someone quickly cancels it,
-// so, it maintains a copy of the QtVersion and emits finished() by name.
-class DebuggingHelperBuildTask : public QObject {
-    Q_OBJECT
-public:
-    explicit DebuggingHelperBuildTask(const QtVersion &version);
-    virtual ~DebuggingHelperBuildTask();
-
-    void run();
-
-signals:
-    void finished(const QString &versionName, const QString &output);
-
-private:
-    QtVersion *m_version;
-};
-
 class QtOptionsPageWidget : public QWidget
 {
     Q_OBJECT
@@ -77,17 +57,11 @@ public:
     void finish();
 
 private:
-    const QPixmap m_debuggingHelperOkPixmap;
-    const QPixmap m_debuggingHelperErrorPixmap;
-    const QIcon m_debuggingHelperOkIcon;
-    const QIcon m_debuggingHelperErrorIcon;
-
     void showEnvironmentPage(QTreeWidgetItem * item);
     void fixQtVersionName(int index);
-    int indexForTreeItem(const QTreeWidgetItem *item) const;
+    int indexForWidget(QWidget *debuggingHelperWidget) const;
+    int indexForTreeItem(QTreeWidgetItem *item) const;
     QTreeWidgetItem *treeItemForIndex(int index) const;
-    QtVersion *currentVersion() const;
-    void updateDebuggingHelperStateLabel(const QtVersion *version = 0);
 
     Internal::Ui::QtVersionManager *m_ui;
     QList<QtVersion *> m_versions;
@@ -115,7 +89,6 @@ private slots:
     void msvcVersionChanged();
     void buildDebuggingHelper();
     void showDebuggingBuildLog();
-    void debuggingHelperBuildFinished(const QString &name, const QString &output);
 };
 
 class QtOptionsPage : public Core::IOptionsPage
@@ -132,7 +105,7 @@ public:
     void apply();
     void finish() { }
 private:
-    QtOptionsPageWidget *m_widget;    
+    QtOptionsPageWidget *m_widget;
 };
 
 } //namespace Internal
diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp
index c5ce9097337..a0680c44589 100644
--- a/src/plugins/qt4projectmanager/qtversionmanager.cpp
+++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp
@@ -1266,10 +1266,8 @@ QString QtVersion::buildDebuggingHelperLibrary()
     // TODO: the debugging helper doesn't comply to actual tool chain yet
     ProjectExplorer::ToolChain *tc = createToolChain(defaultToolchainType());
     tc->addToEnvironment(env);
-    QString output;
-    QString directory = DebuggingHelperLibrary::copyDebuggingHelperLibrary(qtInstallData, path(), &output);
-    if (!directory.isEmpty())
-        output += DebuggingHelperLibrary::buildDebuggingHelperLibrary(directory, tc->makeCommand(), qmakeCommand(), mkspec(), env);
+    QString directory = DebuggingHelperLibrary::copyDebuggingHelperLibrary(qtInstallData, path());
+    QString output = DebuggingHelperLibrary::buildDebuggingHelperLibrary(directory, tc->makeCommand(), qmakeCommand(), mkspec(), env);
     m_hasDebuggingHelper = !debuggingHelperLibrary().isEmpty();
     delete tc;
     return output;
diff --git a/src/plugins/qt4projectmanager/qtversionmanager.ui b/src/plugins/qt4projectmanager/qtversionmanager.ui
index bc716ab3cd8..b92932ece62 100644
--- a/src/plugins/qt4projectmanager/qtversionmanager.ui
+++ b/src/plugins/qt4projectmanager/qtversionmanager.ui
@@ -17,6 +17,31 @@
       <string>Qt versions</string>
      </property>
      <layout class="QGridLayout" name="gridLayout">
+      <item row="0" column="0" colspan="2">
+       <widget class="QTreeWidget" name="qtdirList">
+        <property name="uniformRowHeights">
+         <bool>true</bool>
+        </property>
+        <property name="columnCount">
+         <number>3</number>
+        </property>
+        <column>
+         <property name="text">
+          <string>Name</string>
+         </property>
+        </column>
+        <column>
+         <property name="text">
+          <string>Path</string>
+         </property>
+        </column>
+        <column>
+         <property name="text">
+          <string>Debugging Helper</string>
+         </property>
+        </column>
+       </widget>
+      </item>
       <item row="0" column="2">
        <layout class="QVBoxLayout">
         <property name="spacing">
@@ -66,6 +91,43 @@
         </item>
        </layout>
       </item>
+      <item row="1" column="0">
+       <widget class="QLabel" name="versionNameLabel">
+        <property name="text">
+         <string>Version Name:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1">
+       <widget class="QLineEdit" name="nameEdit"/>
+      </item>
+      <item row="2" column="0">
+       <widget class="QLabel" name="pathLabel">
+        <property name="text">
+         <string>Path:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="1">
+       <widget class="Core::Utils::PathChooser" name="qtPath" native="true"/>
+      </item>
+      <item row="3" column="0">
+       <widget class="QLabel" name="mingwLabel">
+        <property name="text">
+         <string>MinGw Directory:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="1">
+       <widget class="Core::Utils::PathChooser" name="mingwPath" native="true"/>
+      </item>
+      <item row="4" column="0">
+       <widget class="QLabel" name="msvcLabel">
+        <property name="text">
+         <string>MSVC Version:</string>
+        </property>
+       </widget>
+      </item>
       <item row="4" column="1">
        <layout class="QHBoxLayout" name="horizontalLayout">
         <property name="spacing">
@@ -100,6 +162,23 @@ p, li { white-space: pre-wrap; }
         </item>
        </layout>
       </item>
+      <item row="5" column="0">
+       <widget class="QLabel" name="mwcLabel">
+        <property name="text">
+         <string>MWC Directory:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="5" column="1">
+       <widget class="Core::Utils::PathChooser" name="mwcPath" native="true"/>
+      </item>
+      <item row="6" column="0">
+       <widget class="QLabel" name="label">
+        <property name="text">
+         <string>Debugging Helper:</string>
+        </property>
+       </widget>
+      </item>
       <item row="6" column="1">
        <layout class="QHBoxLayout" name="horizontalLayout_2">
         <item>
@@ -131,75 +210,6 @@ p, li { white-space: pre-wrap; }
         </item>
        </layout>
       </item>
-      <item row="0" column="0" colspan="2">
-       <widget class="QTreeWidget" name="qtdirList">
-        <property name="uniformRowHeights">
-         <bool>true</bool>
-        </property>
-        <property name="columnCount">
-         <number>3</number>
-        </property>
-        <column>
-         <property name="text">
-          <string>Name</string>
-         </property>
-        </column>
-        <column>
-         <property name="text">
-          <string>Path</string>
-         </property>
-        </column>
-        <column>
-         <property name="text">
-          <string>Debugging Helper</string>
-         </property>
-        </column>
-       </widget>
-      </item>
-      <item row="1" column="0">
-       <widget class="QLabel" name="versionNameLabel">
-        <property name="text">
-         <string>Version Name:</string>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="1">
-       <widget class="QLineEdit" name="nameEdit"/>
-      </item>
-      <item row="2" column="0">
-       <widget class="QLabel" name="pathLabel">
-        <property name="text">
-         <string>Path:</string>
-        </property>
-       </widget>
-      </item>
-      <item row="2" column="1">
-       <widget class="Core::Utils::PathChooser" name="qtPath"/>
-      </item>
-      <item row="3" column="0">
-       <widget class="QLabel" name="mingwLabel">
-        <property name="text">
-         <string>MinGw Directory:</string>
-        </property>
-       </widget>
-      </item>
-      <item row="3" column="1">
-       <widget class="Core::Utils::PathChooser" name="mingwPath"/>
-      </item>
-      <item row="4" column="0">
-       <widget class="QLabel" name="msvcLabel">
-        <property name="text">
-         <string>MSVC Version:</string>
-        </property>
-       </widget>
-      </item>
-      <item row="6" column="0">
-       <widget class="QLabel" name="debuggingHelperLabel">
-        <property name="text">
-         <string>Debugging Helper:</string>
-        </property>
-       </widget>
-      </item>
       <item row="7" column="1">
        <widget class="QLabel" name="errorLabel">
         <property name="text">
@@ -207,16 +217,6 @@ p, li { white-space: pre-wrap; }
         </property>
        </widget>
       </item>
-      <item row="5" column="0">
-       <widget class="QLabel" name="mwcLabel">
-        <property name="text">
-         <string>MWC Directory:</string>
-        </property>
-       </widget>
-      </item>
-      <item row="5" column="1">
-       <widget class="Core::Utils::PathChooser" name="mwcPath"/>
-      </item>
      </layout>
      <zorder>qtdirList</zorder>
      <zorder>versionNameLabel</zorder>
@@ -226,10 +226,12 @@ p, li { white-space: pre-wrap; }
      <zorder>mingwLabel</zorder>
      <zorder>mingwPath</zorder>
      <zorder>msvcLabel</zorder>
-     <zorder>debuggingHelperLabel</zorder>
+     <zorder>label</zorder>
      <zorder>errorLabel</zorder>
      <zorder>mwcLabel</zorder>
      <zorder>mwcPath</zorder>
+     <zorder>msvcComboBox</zorder>
+     <zorder>msvcNotFoundLabel</zorder>
     </widget>
    </item>
    <item>
-- 
GitLab