diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp
index 5505a2666ca13aa6dd4d547b6e01443a2006fbf9..f1464e1aef73a82a8731ca79b82f6be56ae9f366 100644
--- a/src/plugins/qtsupport/baseqtversion.cpp
+++ b/src/plugins/qtsupport/baseqtversion.cpp
@@ -613,25 +613,7 @@ void BaseQtVersion::updateSourcePath() const
     if (!m_sourcePath.isEmpty())
         return;
     updateVersionInfo();
-    const QString installData = qmakeProperty("QT_INSTALL_PREFIX");
-    QString sourcePath = installData;
-    QFile qmakeCache(installData + QLatin1String("/.qmake.cache"));
-    if (qmakeCache.exists()) {
-        qmakeCache.open(QIODevice::ReadOnly | QIODevice::Text);
-        QTextStream stream(&qmakeCache);
-        while (!stream.atEnd()) {
-            QString line = stream.readLine().trimmed();
-            if (line.startsWith(QLatin1String("QT_SOURCE_TREE"))) {
-                sourcePath = line.split(QLatin1Char('=')).at(1).trimmed();
-                if (sourcePath.startsWith(QLatin1String("$$quote("))) {
-                    sourcePath.remove(0, 8);
-                    sourcePath.chop(1);
-                }
-                break;
-            }
-        }
-    }
-    m_sourcePath = FileName::fromUserInput(sourcePath);
+    m_sourcePath = sourcePath(m_versionInfo);
 }
 
 FileName BaseQtVersion::sourcePath() const
@@ -1441,6 +1423,29 @@ FileName BaseQtVersion::mkspecFromVersionInfo(const QHash<QString, QString> &ver
     return mkspecFullPath;
 }
 
+FileName BaseQtVersion::sourcePath(const QHash<QString, QString> &versionInfo)
+{
+    const QString installData = qmakeProperty(versionInfo, "QT_INSTALL_PREFIX");
+    QString sourcePath = installData;
+    QFile qmakeCache(installData + QLatin1String("/.qmake.cache"));
+    if (qmakeCache.exists()) {
+        qmakeCache.open(QIODevice::ReadOnly | QIODevice::Text);
+        QTextStream stream(&qmakeCache);
+        while (!stream.atEnd()) {
+            QString line = stream.readLine().trimmed();
+            if (line.startsWith(QLatin1String("QT_SOURCE_TREE"))) {
+                sourcePath = line.split(QLatin1Char('=')).at(1).trimmed();
+                if (sourcePath.startsWith(QLatin1String("$$quote("))) {
+                    sourcePath.remove(0, 8);
+                    sourcePath.chop(1);
+                }
+                break;
+            }
+        }
+    }
+    return FileName::fromUserInput(sourcePath);
+}
+
 bool BaseQtVersion::isQmlDebuggingSupported(ProjectExplorer::Kit *k, QString *reason)
 {
     QTC_ASSERT(k, return false);
diff --git a/src/plugins/qtsupport/baseqtversion.h b/src/plugins/qtsupport/baseqtversion.h
index b0e39476da0a0549d978e171fd6bc9f0ffd51921..ac1fcf51a28f23595888c2d5fa5fca1348065e66 100644
--- a/src/plugins/qtsupport/baseqtversion.h
+++ b/src/plugins/qtsupport/baseqtversion.h
@@ -185,6 +185,7 @@ public:
                                     QHash<QString, QString> *versionInfo, QString *error = 0);
     static Utils::FileName mkspecDirectoryFromVersionInfo(const QHash<QString, QString> &versionInfo);
     static Utils::FileName mkspecFromVersionInfo(const QHash<QString, QString> &versionInfo);
+    static Utils::FileName sourcePath(const QHash<QString, QString> &versionInfo);
 
     static bool isQmlDebuggingSupported(ProjectExplorer::Kit *k, QString *reason = 0);
     bool isQmlDebuggingSupported(QString *reason = 0) const;