Qt4ProjectManager: Be more careful in detecing incompatible builds

Task-Nr: QTCREATORBUG-4555

Reviewed-By: hunger
This commit is contained in:
dt
2011-04-19 19:24:30 +02:00
parent acd9e931e3
commit 1dbe498f86
4 changed files with 37 additions and 24 deletions

View File

@@ -328,6 +328,7 @@ void Qt4ProjectConfigWidget::updateImportLabel()
bool visible = false; bool visible = false;
bool targetMatches = false; bool targetMatches = false;
bool incompatibleBuild = false; bool incompatibleBuild = false;
bool couldnotparse = false;
QtVersionManager *vm = QtVersionManager::instance(); QtVersionManager *vm = QtVersionManager::instance();
// we only show if we actually have a qmake and makestep // we only show if we actually have a qmake and makestep
@@ -343,25 +344,31 @@ void Qt4ProjectConfigWidget::updateImportLabel()
// check that there's a makefile // check that there's a makefile
if (!qmakePath.isEmpty()) { if (!qmakePath.isEmpty()) {
// Is it from the same build? // 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; incompatibleBuild = true;
} else if (qmakePath != (version ? version->qmakeCommand() : QString())) { } else if (mc == QtVersionManager::SameProject) {
// and that the qmake path is different from the current version if (qmakePath != (version ? version->qmakeCommand() : QString())) {
// import enable // and that the qmake path is different from the current version
visible = true; // import enable
QtVersion *newVersion = vm->qtVersionForQMakeBinary(qmakePath); visible = true;
bool mustDelete(false); QtVersion *newVersion = vm->qtVersionForQMakeBinary(qmakePath);
if (!newVersion) { bool mustDelete(false);
newVersion = new QtVersion(qmakePath); if (!newVersion) {
mustDelete = true; 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()); } else if (mc == QtVersionManager::CouldNotParse) {
if (mustDelete) couldnotparse = true;
delete newVersion;
} else {
// check that the qmake flags, arguments match
visible = !m_buildConfiguration->compareToImportFrom(makefile);
targetMatches = true;
} }
} }
} }
@@ -409,7 +416,11 @@ void Qt4ProjectConfigWidget::updateImportLabel()
m_ui->problemLabel->setVisible(false); m_ui->problemLabel->setVisible(false);
m_ui->warningLabel->setVisible(false); m_ui->warningLabel->setVisible(false);
m_ui->importLabel->setVisible(visible); 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->warningLabel->setVisible(visible);
m_ui->problemLabel->setVisible(visible); m_ui->problemLabel->setVisible(visible);
m_ui->problemLabel->setText(tr("An incompatible build exists in %1, which will be overwritten.", m_ui->problemLabel->setText(tr("An incompatible build exists in %1, which will be overwritten.",

View File

@@ -1081,7 +1081,7 @@ BuildConfigurationInfo BuildConfigurationInfo::checkForBuild(const QString &dire
QString qmakeBinary = QtVersionManager::findQMakeBinaryFromMakefile(makefile); QString qmakeBinary = QtVersionManager::findQMakeBinaryFromMakefile(makefile);
if (qmakeBinary.isEmpty()) if (qmakeBinary.isEmpty())
return BuildConfigurationInfo(); return BuildConfigurationInfo();
if (!QtVersionManager::makefileIsFor(makefile, proFilePath)) if (QtVersionManager::makefileIsFor(makefile, proFilePath) != QtVersionManager::SameProject)
return BuildConfigurationInfo(); return BuildConfigurationInfo();
bool temporaryQtVersion = false; bool temporaryQtVersion = false;

View File

@@ -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()) if (proFile.isEmpty())
return true; return CouldNotParse;
QString line = findQMakeLine(makefile, QLatin1String("# Project:")).trimmed(); QString line = findQMakeLine(makefile, QLatin1String("# Project:")).trimmed();
if (line.isEmpty()) if (line.isEmpty())
return false; return CouldNotParse;
line = line.mid(line.indexOf(QChar(':')) + 1); line = line.mid(line.indexOf(QChar(':')) + 1);
line = line.trimmed(); line = line.trimmed();
QFileInfo srcFileInfo(QFileInfo(makefile).absoluteDir(), line); QFileInfo srcFileInfo(QFileInfo(makefile).absoluteDir(), line);
QFileInfo proFileInfo(proFile); QFileInfo proFileInfo(proFile);
return srcFileInfo == proFileInfo; return (srcFileInfo == proFileInfo) ? SameProject : DifferentProject;
} }
QPair<QtVersion::QmakeBuildConfigs, QString> QtVersionManager::scanMakeFile(const QString &makefile, QtVersion::QmakeBuildConfigs defaultBuildConfig) QPair<QtVersion::QmakeBuildConfigs, QString> QtVersionManager::scanMakeFile(const QString &makefile, QtVersion::QmakeBuildConfigs defaultBuildConfig)

View File

@@ -287,7 +287,9 @@ public:
QSet<QString> supportedTargetIds() const; QSet<QString> supportedTargetIds() const;
// Static Methods // 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, static QPair<QtVersion::QmakeBuildConfigs, QString> scanMakeFile(const QString &makefile,
QtVersion::QmakeBuildConfigs defaultBuildConfig); QtVersion::QmakeBuildConfigs defaultBuildConfig);
static QString findQMakeBinaryFromMakefile(const QString &directory); static QString findQMakeBinaryFromMakefile(const QString &directory);