diff --git a/src/plugins/qt4projectmanager/qmakeprofileinformation.cpp b/src/plugins/qt4projectmanager/qmakeprofileinformation.cpp index 348e939c31c..1aa4e5e7746 100644 --- a/src/plugins/qt4projectmanager/qmakeprofileinformation.cpp +++ b/src/plugins/qt4projectmanager/qmakeprofileinformation.cpp @@ -63,19 +63,8 @@ unsigned int QmakeProfileInformation::priority() const QVariant QmakeProfileInformation::defaultValue(ProjectExplorer::Profile *p) const { - QtSupport::BaseQtVersion *version = QtSupport::QtProfileInformation::qtVersion(p); - if (!version) // No version, so no qmake - return QString(); - - ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainProfileInformation::toolChain(p); - - const QList tcSpecList = tc ? tc->suggestedMkspecList() : QList(); - foreach (const Utils::FileName &tcSpec, tcSpecList) { - if (version->hasMkspec(tcSpec)) - return tcSpec.toString(); - } - - return version ? version->mkspec().toString() : QString(); + Q_UNUSED(p); + return QString(); } QList QmakeProfileInformation::validate(ProjectExplorer::Profile *p) const @@ -115,9 +104,39 @@ Utils::FileName QmakeProfileInformation::mkspec(const ProjectExplorer::Profile * return Utils::FileName::fromString(p->value(Core::Id(Internal::MKSPEC_INFORMATION)).toString()); } +Utils::FileName QmakeProfileInformation::effectiveMkspec(const ProjectExplorer::Profile *p) +{ + if (!p) + return Utils::FileName(); + Utils::FileName spec = mkspec(p); + if (spec.isEmpty()) + return defaultMkspec(p); + return spec; +} + void QmakeProfileInformation::setMkspec(ProjectExplorer::Profile *p, const Utils::FileName &fn) { - p->setValue(Core::Id(Internal::MKSPEC_INFORMATION), fn.toString()); + if (fn == defaultMkspec(p)) + p->setValue(Core::Id(Internal::MKSPEC_INFORMATION), QString()); + else + p->setValue(Core::Id(Internal::MKSPEC_INFORMATION), fn.toString()); +} + +Utils::FileName QmakeProfileInformation::defaultMkspec(const ProjectExplorer::Profile *p) +{ + QtSupport::BaseQtVersion *version = QtSupport::QtProfileInformation::qtVersion(p); + if (!version) // No version, so no qmake + return Utils::FileName(); + + ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainProfileInformation::toolChain(p); + + const QList tcSpecList = tc ? tc->suggestedMkspecList() : QList(); + foreach (const Utils::FileName &tcSpec, tcSpecList) { + if (version->hasMkspec(tcSpec)) + return tcSpec; + } + + return version ? version->mkspec() : Utils::FileName(); } } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qmakeprofileinformation.h b/src/plugins/qt4projectmanager/qmakeprofileinformation.h index 013f102e49f..8b002c42c74 100644 --- a/src/plugins/qt4projectmanager/qmakeprofileinformation.h +++ b/src/plugins/qt4projectmanager/qmakeprofileinformation.h @@ -58,8 +58,11 @@ public: ItemList toUserOutput(ProjectExplorer::Profile *p) const; - static Utils::FileName mkspec(const ProjectExplorer::Profile *p); static void setMkspec(ProjectExplorer::Profile *p, const Utils::FileName &fn); + static Utils::FileName mkspec(const ProjectExplorer::Profile *p); + static Utils::FileName effectiveMkspec(const ProjectExplorer::Profile *p); + static Utils::FileName defaultMkspec(const ProjectExplorer::Profile *p); + }; } // namespace Qt4ProjectManager