Commit 1dbe498f authored by dt's avatar dt
Browse files

Qt4ProjectManager: Be more careful in detecing incompatible builds

Task-Nr: QTCREATORBUG-4555

Reviewed-By: hunger
parent acd9e931
......@@ -328,6 +328,7 @@ void Qt4ProjectConfigWidget::updateImportLabel()
bool visible = false;
bool targetMatches = false;
bool incompatibleBuild = false;
bool couldnotparse = false;
QtVersionManager *vm = QtVersionManager::instance();
// we only show if we actually have a qmake and makestep
......@@ -343,25 +344,31 @@ void Qt4ProjectConfigWidget::updateImportLabel()
// check that there's a makefile
if (!qmakePath.isEmpty()) {
// Is it from the same build?
if (!QtVersionManager::makefileIsFor(makefile, m_buildConfiguration->target()->project()->file()->fileName())) {
QtVersionManager::MakefileCompatible mc =
QtVersionManager::makefileIsFor(makefile, m_buildConfiguration->target()->project()->file()->fileName());
if (mc == QtVersionManager::DifferentProject) {
incompatibleBuild = true;
} else if (qmakePath != (version ? version->qmakeCommand() : QString())) {
// and that the qmake path is different from the current version
// import enable
visible = true;
QtVersion *newVersion = vm->qtVersionForQMakeBinary(qmakePath);
bool mustDelete(false);
if (!newVersion) {
newVersion = new QtVersion(qmakePath);
mustDelete = true;
} else if (mc == QtVersionManager::SameProject) {
if (qmakePath != (version ? version->qmakeCommand() : QString())) {
// and that the qmake path is different from the current version
// import enable
visible = true;
QtVersion *newVersion = vm->qtVersionForQMakeBinary(qmakePath);
bool mustDelete(false);
if (!newVersion) {
newVersion = new QtVersion(qmakePath);
mustDelete = true;
}
targetMatches = newVersion->supportsTargetId(m_buildConfiguration->target()->id());
if (mustDelete)
delete newVersion;
} else {
// check that the qmake flags, arguments match
visible = !m_buildConfiguration->compareToImportFrom(makefile);
targetMatches = true;
}
targetMatches = newVersion->supportsTargetId(m_buildConfiguration->target()->id());
if (mustDelete)
delete newVersion;
} else {
// check that the qmake flags, arguments match
visible = !m_buildConfiguration->compareToImportFrom(makefile);
targetMatches = true;
} else if (mc == QtVersionManager::CouldNotParse) {
couldnotparse = true;
}
}
}
......@@ -409,7 +416,11 @@ void Qt4ProjectConfigWidget::updateImportLabel()
m_ui->problemLabel->setVisible(false);
m_ui->warningLabel->setVisible(false);
m_ui->importLabel->setVisible(visible);
} else {
} else if (couldnotparse) {
m_ui->problemLabel->setVisible(false);
m_ui->warningLabel->setVisible(false);
m_ui->importLabel->setVisible(false);
} else { // target did not match
m_ui->warningLabel->setVisible(visible);
m_ui->problemLabel->setVisible(visible);
m_ui->problemLabel->setText(tr("An incompatible build exists in %1, which will be overwritten.",
......
......@@ -1081,7 +1081,7 @@ BuildConfigurationInfo BuildConfigurationInfo::checkForBuild(const QString &dire
QString qmakeBinary = QtVersionManager::findQMakeBinaryFromMakefile(makefile);
if (qmakeBinary.isEmpty())
return BuildConfigurationInfo();
if (!QtVersionManager::makefileIsFor(makefile, proFilePath))
if (QtVersionManager::makefileIsFor(makefile, proFilePath) != QtVersionManager::SameProject)
return BuildConfigurationInfo();
bool temporaryQtVersion = false;
......
......@@ -1011,21 +1011,21 @@ void dumpQMakeAssignments(const QList<QMakeAssignment> &list)
}
}
bool QtVersionManager::makefileIsFor(const QString &makefile, const QString &proFile)
QtVersionManager::MakefileCompatible QtVersionManager::makefileIsFor(const QString &makefile, const QString &proFile)
{
if (proFile.isEmpty())
return true;
return CouldNotParse;
QString line = findQMakeLine(makefile, QLatin1String("# Project:")).trimmed();
if (line.isEmpty())
return false;
return CouldNotParse;
line = line.mid(line.indexOf(QChar(':')) + 1);
line = line.trimmed();
QFileInfo srcFileInfo(QFileInfo(makefile).absoluteDir(), line);
QFileInfo proFileInfo(proFile);
return srcFileInfo == proFileInfo;
return (srcFileInfo == proFileInfo) ? SameProject : DifferentProject;
}
QPair<QtVersion::QmakeBuildConfigs, QString> QtVersionManager::scanMakeFile(const QString &makefile, QtVersion::QmakeBuildConfigs defaultBuildConfig)
......
......@@ -287,7 +287,9 @@ public:
QSet<QString> supportedTargetIds() const;
// Static Methods
static bool makefileIsFor(const QString &makefile, const QString &proFile);
enum MakefileCompatible { CouldNotParse, DifferentProject, SameProject };
static MakefileCompatible makefileIsFor(const QString &makefile, const QString &proFile);
static QPair<QtVersion::QmakeBuildConfigs, QString> scanMakeFile(const QString &makefile,
QtVersion::QmakeBuildConfigs defaultBuildConfig);
static QString findQMakeBinaryFromMakefile(const QString &directory);
......
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