Commit e3188417 authored by dt's avatar dt

Don't silently reset the qt version if it has become invalid

Instead note that it is invalid if trying to build and on the projects
mode pane.

Task-Nr: QTCREATORBUG-459
parent b407810b
......@@ -109,10 +109,13 @@ bool QMakeStep::init()
if (!qtVersion->isValid()) {
#if defined(Q_WS_MAC)
emit addOutput(tr("\n<font color=\"#ff0000\"><b>No valid Qt version set. Set one in Preferences </b></font>\n"));
emit addOutput(tr("<font color=\"#ff0000\">Qt version <b>%1</b> is invalid. Set a valid Qt Version in Preferences </font>\n")
.arg(qtVersion->displayName()));
#else
emit addOutput(tr("\n<font color=\"#ff0000\"><b>No valid Qt version set. Set one in Tools/Options </b></font>\n"));
emit addOutput(tr("<font color=\"#ff0000\">Qt version <b>%1</b> is invalid. Set valid Qt Version in Tools/Options </b></font>\n")
.arg(qtVersion->displayName()));
#endif
emit addOutput("<font color=\"#ff0000\">" + qtVersion->invalidReason() + "</font><br>");
return false;
}
......
......@@ -71,6 +71,9 @@ Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4Project *pro, const QMap<QString
m_shadowBuild = map.value("useShadowBuild").toBool();
m_buildDirectory = map.value("buildDirectory").toString();
m_qtVersion = map.value(KEY_QT_VERSION_ID).toInt();
if (!QtVersionManager::instance()->isValidId(m_qtVersion))
m_qtVersion = 0;
m_toolChainType = map.value("ToolChain").toInt();
m_qmakeBuildConfiguration = QtVersion::QmakeBuildConfigs(map.value("buildConfiguration").toInt());
}
......@@ -258,20 +261,15 @@ QtVersion *Qt4BuildConfiguration::qtVersion() const
int Qt4BuildConfiguration::qtVersionId() const
{
QtVersionManager *vm = QtVersionManager::instance();
if (debug)
qDebug()<<"Looking for qtVersion ID of "<<displayName();
if (vm->version(m_qtVersion)->isValid()) {
return m_qtVersion;
} else {
m_qtVersion = 0;
return 0;
}
return m_qtVersion;
}
void Qt4BuildConfiguration::setQtVersion(int id)
{
if (qtVersionId() == id)
if (m_qtVersion == id)
return;
if (!QtVersionManager::instance()->isValidId(id))
return;
m_qtVersion = id;
......
......@@ -114,6 +114,8 @@ Qt4ProjectConfigWidget::~Qt4ProjectConfigWidget()
void Qt4ProjectConfigWidget::updateDetails()
{
QtVersion *version = m_buildConfiguration->qtVersion();
QString versionString;
if (m_buildConfiguration->qtVersionId() == 0) {
versionString = tr("Default Qt Version (%1)").arg(version->displayName());
......@@ -122,13 +124,24 @@ void Qt4ProjectConfigWidget::updateDetails()
} else {
versionString = tr("No Qt Version set");
}
// Qt Version, Build Directory and Toolchain
m_detailsContainer->setSummaryText(tr("using Qt version: <b>%1</b><br>"
"with tool chain <b>%2</b><br>"
"building in <b>%3</b>")
.arg(versionString,
ProjectExplorer::ToolChain::toolChainName(m_buildConfiguration->toolChainType()),
QDir::toNativeSeparators(m_buildConfiguration->buildDirectory())));
if (!version->isValid()) {
// Not a valid qt version
m_detailsContainer->setSummaryText(
tr("using <font color=\"#ff0000\">invalid</font> Qt Version: <b>%1</b><br>"
"%2")
.arg(versionString,
version->invalidReason()));
} else {
// Qt Version, Build Directory and Toolchain
m_detailsContainer->setSummaryText(
tr("using Qt version: <b>%1</b><br>"
"with tool chain <b>%2</b><br>"
"building in <b>%3</b>")
.arg(versionString,
ProjectExplorer::ToolChain::toolChainName(m_buildConfiguration->toolChainType()),
QDir::toNativeSeparators(m_buildConfiguration->buildDirectory())));
}
}
void Qt4ProjectConfigWidget::manageQtVersions()
......
......@@ -513,9 +513,8 @@ void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item)
makeMSVCVisible(false);
makeMingwVisible(false);
makeS60Visible(false);
if (!m_versions.at(index)->isInstalled())
m_ui->errorLabel->setText(tr("The Qt Version identified by %1 is not installed. Run make install")
.arg(QDir::toNativeSeparators(m_versions.at(index)->qmakeCommand())));
if (!m_versions.at(index)->isValid())
m_ui->errorLabel->setText(m_versions.at(index)->invalidReason());
else
m_ui->errorLabel->setText(tr("%1 does not specify a valid Qt installation").arg(QDir::toNativeSeparators(m_versions.at(index)->qmakeCommand())));
} else { //ProjectExplorer::ToolChain::GCC
......
......@@ -278,6 +278,12 @@ QList<QtVersion* > QtVersionManager::versions() const
return m_versions;
}
bool QtVersionManager::isValidId(int id) const
{
int pos = m_uniqueIdToIndex.value(id, -1);
return (pos != -1);
}
QtVersion *QtVersionManager::version(int id) const
{
int pos = m_uniqueIdToIndex.value(id, -1);
......@@ -1015,12 +1021,6 @@ void QtVersion::updateVersionInfo() const
m_versionInfoUpToDate = true;
}
bool QtVersion::isInstalled() const
{
updateVersionInfo();
return !m_notInstalled;
}
QString QtVersion::findQtBinary(const QStringList &possibleCommands) const
{
const QString qtdirbin = versionInfo().value(QLatin1String("QT_INSTALL_BINS")) + QLatin1Char('/');
......@@ -1359,8 +1359,26 @@ int QtVersion::getUniqueId()
bool QtVersion::isValid() const
{
updateVersionInfo();
return (!(m_id == -1 || qmakeCommand() == QString::null
|| displayName() == QString::null) && !m_notInstalled);
return m_id != -1
&& qmakeCommand() != QString::null
&& displayName() != QString::null
&& !m_notInstalled
&& m_versionInfo.contains("QT_INSTALL_BINS");
}
QString QtVersion::invalidReason() const
{
if (isValid())
return QString();
if (qmakeCommand() == QString::null)
return QApplication::translate("QtVersion", "No QMake path set");
if (displayName() == QString::null)
return QApplication::translate("QtVersion", "Qt Version has no name");
if (m_notInstalled)
return QApplication::translate("QtVersion", "Qt Version is not installed, please run make install");
if (!m_versionInfo.contains("QT_INSTALL_BINS"))
return QApplication::translate("QtVersion", "Could not determine qt install binary, maybe the qmake path is wrong?");
return QString();
}
QtVersion::QmakeBuildConfigs QtVersion::defaultBuildConfig() const
......
......@@ -64,7 +64,7 @@ public:
~QtVersion();
bool isValid() const; //TOOD check that the dir exists and the name is non empty
bool isInstalled() const;
QString invalidReason() const;
bool isAutodetected() const { return m_isAutodetected; }
QString autodetectionSource() const { return m_autodetectionSource; }
......@@ -211,6 +211,7 @@ public:
static QPair<QtVersion::QmakeBuildConfigs, QStringList> scanMakeFile(const QString &directory,
QtVersion::QmakeBuildConfigs defaultBuildConfig);
static QString findQMakeBinaryFromMakefile(const QString &directory);
bool isValidId(int id) const;
signals:
void defaultQtVersionChanged();
void qtVersionsChanged(const QList<int> &uniqueIds);
......
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