Commit d1c23f58 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Preserve invalid Qt versions when loading a project

Now that we have 2.0 out we can be less strict when checking
project consistency when loading .user files.  The strictness
was necessary due to upgrading non-target projects to target
projects.

 * Allow for invalid Qt versions when loading a .user file that was not
   updated from the pre-target era.
 * Update the UI to show invalid Qt versions as invalid. Remove
   the Invalid version as soon as a valid one is imported.

This does preserve the buildsteps, too.
parent 6b3132a6
......@@ -32,12 +32,14 @@
#include "editorconfiguration.h"
#include "environment.h"
#include "projectexplorer.h"
#include "projectexplorerconstants.h"
#include "projectnodes.h"
#include "target.h"
#include "userfileaccessor.h"
#include <coreplugin/ifile.h>
#include <extensionsystem/pluginmanager.h>
#include <limits>
#include <utils/qtcassert.h>
using namespace ProjectExplorer;
......@@ -247,6 +249,9 @@ bool Project::fromMap(const QVariantMap &map)
m_editorConfiguration->fromMap(values);
}
int previousFileVersion = map.value(QLatin1String(Constants::USERFILE_PREVIOUS_VERSION_KEY),
std::numeric_limits<int>::max()).toInt();
bool ok;
int maxI(map.value(QLatin1String(TARGET_COUNT_KEY), 0).toInt(&ok));
if (!ok || maxI < 0)
......@@ -263,7 +268,9 @@ bool Project::fromMap(const QVariantMap &map)
qWarning() << key << "was not found in data.";
return false;
}
Target *t(targetFactory()->restore(this, map.value(key).toMap()));
QVariantMap targetMap = map.value(key).toMap();
targetMap.insert(Constants::USERFILE_PREVIOUS_VERSION_KEY, previousFileVersion);
Target *t(targetFactory()->restore(this, targetMap));
if (!t) {
qWarning() << "Restoration of a target failed! (Continuing)";
continue;
......
......@@ -239,6 +239,7 @@ bool RunConfiguration::fromMap(const QVariantMap &map)
m_useCppDebugger = map.value(QLatin1String(USE_CPP_DEBUGGER_KEY), true).toBool();
m_useQmlDebugger = map.value(QLatin1String(USE_QML_DEBUGGER_KEY), false).toBool();
m_qmlDebugServerPort = map.value(QLatin1String(QML_DEBUG_SERVER_PORT_KEY), Constants::QML_DEFAULT_DEBUG_SERVER_PORT).toUInt();
return ProjectConfiguration::fromMap(map);
}
......
......@@ -32,8 +32,10 @@
#include "buildconfiguration.h"
#include "deployconfiguration.h"
#include "project.h"
#include "projectexplorerconstants.h"
#include "runconfiguration.h"
#include <limits>
#include <utils/qtcassert.h>
using namespace ProjectExplorer;
......@@ -353,6 +355,9 @@ bool Target::fromMap(const QVariantMap &map)
if (!ProjectConfiguration::fromMap(map))
return false;
int fileVersion = map.value(Constants::USERFILE_PREVIOUS_VERSION_KEY,
std::numeric_limits<int>::max()).toInt();
bool ok;
int bcCount(map.value(QLatin1String(BC_COUNT_KEY), 0).toInt(&ok));
if (!ok || bcCount < 0)
......@@ -367,7 +372,9 @@ bool Target::fromMap(const QVariantMap &map)
const QString key(QString::fromLatin1(BC_KEY_PREFIX) + QString::number(i));
if (!map.contains(key))
return false;
BuildConfiguration *bc(buildConfigurationFactory()->restore(this, map.value(key).toMap()));
QVariantMap targetMap = map.value(key).toMap();
targetMap.insert(Constants::USERFILE_PREVIOUS_VERSION_KEY, fileVersion);
BuildConfiguration *bc(buildConfigurationFactory()->restore(this, targetMap));
if (!bc)
continue;
addBuildConfiguration(bc);
......
......@@ -37,6 +37,7 @@
#include "makestep.h"
#include <utils/qtcassert.h>
#include <limits>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/projectexplorerconstants.h>
......@@ -117,6 +118,8 @@ bool Qt4BuildConfiguration::fromMap(const QVariantMap &map)
if (!BuildConfiguration::fromMap(map))
return false;
int fileVersion = map.value(ProjectExplorer::Constants::USERFILE_PREVIOUS_VERSION_KEY,
std::numeric_limits<int>::max()).toInt();
m_shadowBuild = map.value(QLatin1String(USE_SHADOW_BUILD_KEY), true).toBool();
m_buildDirectory = map.value(QLatin1String(BUILD_DIRECTORY_KEY), qt4Target()->defaultBuildDirectory()).toString();
m_qtVersionId = map.value(QLatin1String(QT_VERSION_ID_KEY)).toInt();
......@@ -124,8 +127,8 @@ bool Qt4BuildConfiguration::fromMap(const QVariantMap &map)
m_qmakeBuildConfiguration = QtVersion::QmakeBuildConfigs(map.value(QLatin1String(BUILD_CONFIGURATION_KEY)).toInt());
// Pick a Qt version if the default version is used:
// We assume that the default Qt version as used in earlier versions of Qt creator
// was supporting a desktop flavor of Qt.
// We assume that the default Qt version was used in earlier versions of Qt creator.
// Pick a Qt version that is supporting a desktop.
if (m_qtVersionId == 0) {
QList<QtVersion *> versions = QtVersionManager::instance()->versions();
foreach (QtVersion *v, versions) {
......@@ -139,12 +142,20 @@ bool Qt4BuildConfiguration::fromMap(const QVariantMap &map)
}
QtVersion *version = qtVersion();
if (!version->isValid() || !version->supportedTargetIds().contains(target()->id())) {
qWarning() << "Buildconfiguration" << displayName() << ": Qt" << version->displayName() << "not supported by target" << target()->id();
return false;
if (fileVersion >= 1) { // we are not upgrading from pre-targets!
if (version->isValid() && !version->supportedTargetIds().contains(target()->id())) {
qWarning() << "Buildconfiguration" << displayName() << ": Qt" << version->displayName() << "not supported by target" << target()->id();
return false;
}
} else {
if (!version->isValid() || !version->supportedTargetIds().contains(target()->id())) {
qWarning() << "Buildconfiguration" << displayName() << ": Qt" << version->displayName() << "not supported by target" << target()->id();
return false;
}
}
m_shadowBuild = (m_shadowBuild && version->isValid() && version->supportsShadowBuilds());
if (version->isValid())
m_shadowBuild = (m_shadowBuild && version->supportsShadowBuilds());
QList<ToolChain::ToolChainType> possibleTcs(qt4Target()->filterToolChainTypes(qtVersion()->possibleToolChainTypes()));
if (!possibleTcs.contains(toolChainType()))
......@@ -325,6 +336,8 @@ void Qt4BuildConfiguration::setQtVersion(QtVersion *version)
m_toolChainType = candidates.first();
}
m_shadowBuild = m_shadowBuild && qtVersion()->supportsShadowBuilds();
emit proFileEvaluateNeeded(this);
emit qtVersionChanged();
emit environmentChanged();
......
......@@ -77,7 +77,6 @@ Qt4ProjectConfigWidget::Qt4ProjectConfigWidget(Qt4Project *project)
m_ui->shadowBuildDirEdit->setPromptDialogTitle(tr("Shadow Build Directory"));
m_ui->shadowBuildDirEdit->setExpectedKind(Utils::PathChooser::Directory);
m_ui->invalidQtWarningLabel->setVisible(false);
connect(m_ui->shadowBuildCheckBox, SIGNAL(clicked(bool)),
this, SLOT(shadowBuildClicked(bool)));
......@@ -150,12 +149,6 @@ void Qt4ProjectConfigWidget::manageQtVersions()
core->showOptionsDialog(Constants::QT_SETTINGS_CATEGORY, Constants::QTVERSION_SETTINGS_PAGE_ID);
}
void Qt4ProjectConfigWidget::updateInvalidQtVersion()
{
m_ui->invalidQtWarningLabel->setVisible(!m_buildConfiguration->qtVersion()->isValid());
}
QString Qt4ProjectConfigWidget::displayName() const
{
return tr("General");
......@@ -234,16 +227,17 @@ void Qt4ProjectConfigWidget::qtVersionsChanged()
m_ui->qtVersionComboBox->addItem(validVersions.at(i)->displayName(),
validVersions.at(i)->uniqueId());
if (validVersions.at(i) == qtVersion) {
if (validVersions.at(i) == qtVersion)
m_ui->qtVersionComboBox->setCurrentIndex(i);
m_ui->invalidQtWarningLabel->setVisible(!validVersions.at(i)->isValid());
}
}
m_ui->qtVersionComboBox->setEnabled(validVersions.count() > 1);
}
if (!qtVersion->isValid()) {
m_ui->qtVersionComboBox->addItem(tr("Invalid Qt version"), -1);
m_ui->qtVersionComboBox->setCurrentIndex(m_ui->qtVersionComboBox->count() - 1);
}
m_ignoreChange = false;
updateInvalidQtVersion();
updateToolChainCombo();
updateShadowBuildUi();
updateDetails();
......@@ -440,9 +434,12 @@ void Qt4ProjectConfigWidget::qtVersionSelected(const QString &)
{
if (m_ignoreChange)
return;
//Qt Version
int newQtVersionId = m_ui->qtVersionComboBox->itemData(m_ui->qtVersionComboBox->currentIndex()).toInt();
if (m_ui->qtVersionComboBox->itemData(m_ui->qtVersionComboBox->count() - 1).toInt() == -1)
m_ui->qtVersionComboBox->removeItem(m_ui->qtVersionComboBox->count() - 1);
QtVersionManager *vm = QtVersionManager::instance();
QtVersion *newQtVersion = vm->version(newQtVersionId);
......@@ -450,7 +447,6 @@ void Qt4ProjectConfigWidget::qtVersionSelected(const QString &)
m_buildConfiguration->setQtVersion(newQtVersion);
m_ignoreChange = false;
updateInvalidQtVersion();
updateShadowBuildUi();
updateToolChainCombo();
updateImportLabel();
......
......@@ -81,7 +81,7 @@ private:
void updateDetails();
void updateToolChainCombo();
void updateShadowBuildUi();
void updateInvalidQtVersion();
Ui::Qt4ProjectConfigWidget *m_ui;
QAbstractButton *m_browseButton;
Qt4BuildConfiguration *m_buildConfiguration;
......
......@@ -39,19 +39,6 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="invalidQtWarningLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>This Qt version is invalid.</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="manageQtVersionPushButtons">
<property name="text">
......
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