Commit 88a36fe3 authored by Kai Koehne's avatar Kai Koehne
Browse files

DebuggingHelpers: Check for Qt version instead checking private files

The location private includes might still change with 4.7.1 . Better
check the qt version string.

Reviewed-by: Lasse Holmstedt
parent a9514a38
......@@ -101,6 +101,33 @@ QString BuildableHelperLibrary::qtVersionForQMake(const QString &qmakePath)
return QString();
}
bool BuildableHelperLibrary::checkMinimumQtVersion(const QString &qtVersionString, int majorVersion, int minorVersion, int patchVersion)
{
int major = -1;
int minor = -1;
int patch = -1;
// check format
QRegExp qtVersionRegex(QLatin1String("^\\d+\\.\\d+\\.\\d+$"));
if (!qtVersionRegex.exactMatch(qtVersionString))
return false;
QStringList parts = qtVersionString.split(QLatin1Char('.'));
major = parts.at(0).toInt();
minor = parts.at(1).toInt();
patch = parts.at(2).toInt();
if (major == majorVersion) {
if (minor == minorVersion) {
if (patch >= patchVersion)
return true;
} else if (minor > minorVersion)
return true;
}
return false;
}
QStringList BuildableHelperLibrary::possibleQMakeCommands()
{
// On windows no one has renamed qmake, right?
......
......@@ -19,6 +19,7 @@ public:
static QString findSystemQt(const Utils::Environment &env);
// return true if the qmake at qmakePath is qt4 (used by QtVersion)
static QString qtVersionForQMake(const QString &qmakePath);
static bool checkMinimumQtVersion(const QString &qtversionString, int majorVersion, int minorVersion, int patchVersion);
// returns something like qmake4, qmake, qmake-qt4 or whatever distributions have chosen (used by QtVersion)
static QStringList possibleQMakeCommands();
......
......@@ -50,10 +50,9 @@ static inline QStringList validBinaryFilenames()
<< QLatin1String("qmldump.app/Contents/MacOS/qmldump");
}
bool QmlDumpTool::canBuild(const QString &installHeadersDir)
bool QmlDumpTool::canBuild(QtVersion *qtVersion)
{
QString qDeclHeader = installHeadersDir + QLatin1String("/QtDeclarative/private/qdeclarativemetatype_p.h");
return QFile::exists(qDeclHeader);
return checkMinimumQtVersion(qtVersion->qtVersionString(), 4, 7, 0);
}
QString QmlDumpTool::toolForProject(ProjectExplorer::Project *project)
......
......@@ -42,11 +42,12 @@ namespace ProjectExplorer {
}
namespace Qt4ProjectManager {
class QtVersion;
class QT4PROJECTMANAGER_EXPORT QmlDumpTool : public Utils::BuildableHelperLibrary
{
public:
static bool canBuild(const QString &installHeadersDir);
static bool canBuild(QtVersion *qtVersion);
static QString toolForProject(ProjectExplorer::Project *project);
static QString toolByInstallData(const QString &qtInstallData);
static QStringList locationsByInstallData(const QString &qtInstallData);
......
......@@ -32,6 +32,7 @@
#include "qt4project.h"
#include "qt4projectmanagerconstants.h"
#include <coreplugin/icore.h>
#include <utils/qtcassert.h>
#include <projectexplorer/project.h>
#include <QDesktopServices>
......@@ -50,10 +51,9 @@ static inline QStringList validBinaryFilenames()
<< QLatin1String("QMLObserver.app/Contents/MacOS/QMLObserver");
}
bool QmlObserverTool::canBuild(const QString &installHeadersDir)
bool QmlObserverTool::canBuild(QtVersion *qtVersion)
{
QString qDeclHeader = installHeadersDir + QLatin1String("/QtDeclarative/private/qdeclarativemetatype_p.h");
return QFile::exists(qDeclHeader);
return checkMinimumQtVersion(qtVersion->qtVersionString(), 4, 7, 1);
}
QString QmlObserverTool::toolForProject(ProjectExplorer::Project *project)
......
......@@ -43,10 +43,12 @@ namespace ProjectExplorer {
namespace Qt4ProjectManager {
class QtVersion;
class QT4PROJECTMANAGER_EXPORT QmlObserverTool : public Utils::BuildableHelperLibrary
{
public:
static bool canBuild(const QString &installHeadersDir);
static bool canBuild(QtVersion *qtVersion);
static QString toolForProject(ProjectExplorer::Project *project);
static QString toolByInstallData(const QString &qtInstallData);
static QStringList locationsByInstallData(const QString &qtInstallData);
......
......@@ -1770,7 +1770,7 @@ QString QtVersion::buildDebuggingHelperLibrary(QFutureInterface<void> &future)
}
future.setProgressValue(2);
if (QmlDumpTool::canBuild(qtInstallHeaders)) {
if (QmlDumpTool::canBuild(this)) {
QString toolDirectory = QmlDumpTool::copy(qtInstallData, &output);
if (!toolDirectory.isEmpty()) {
output += QmlDumpTool::build(toolDirectory, tc->makeCommand(),
......@@ -1782,7 +1782,7 @@ QString QtVersion::buildDebuggingHelperLibrary(QFutureInterface<void> &future)
}
future.setProgressValue(3);
if (QmlObserverTool::canBuild(qtInstallHeaders)) {
if (QmlObserverTool::canBuild(this)) {
QString toolDirectory = QmlObserverTool::copy(qtInstallData, &output);
if (!toolDirectory.isEmpty()) {
output += QmlObserverTool::build(toolDirectory, tc->makeCommand(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment