forked from qt-creator/qt-creator
Revert "ProjectExplorer: Remove toolchain settings compatibility with <= 4.3"
This reverts commit 6baf09bf91.
sdktool still writes the toolchains with the old settings key.
This should be changed in a follow-up commit, but since we missed
updating the key used in sdktool, we have to stay compatible with that
for a longer while still, or we break lots of existing Qt installations
out there (specifically Boot2Qt, which is the main user of the sdktool
operation).
Fixes: QTCREATORBUG-25647
Change-Id: Ie665c9db5fd5bb808f510c53fd4173b8a318bb7c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -44,6 +44,7 @@ using namespace Utils;
|
||||
static const char ID_KEY[] = "ProjectExplorer.ToolChain.Id";
|
||||
static const char DISPLAY_NAME_KEY[] = "ProjectExplorer.ToolChain.DisplayName";
|
||||
static const char AUTODETECT_KEY[] = "ProjectExplorer.ToolChain.Autodetect";
|
||||
static const char LANGUAGE_KEY_V1[] = "ProjectExplorer.ToolChain.Language"; // For QtCreator <= 4.2
|
||||
static const char LANGUAGE_KEY_V2[] = "ProjectExplorer.ToolChain.LanguageV2"; // For QtCreator > 4.2
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -86,8 +87,41 @@ public:
|
||||
ToolChain::HeaderPathsCache m_headerPathsCache;
|
||||
};
|
||||
|
||||
} // Internal
|
||||
|
||||
// Deprecated used from QtCreator <= 4.2
|
||||
|
||||
Utils::Id fromLanguageV1(int language)
|
||||
{
|
||||
switch (language)
|
||||
{
|
||||
case Deprecated::Toolchain::C :
|
||||
return Utils::Id(Constants::C_LANGUAGE_ID);
|
||||
case Deprecated::Toolchain::Cxx:
|
||||
return Utils::Id(Constants::CXX_LANGUAGE_ID);
|
||||
case Deprecated::Toolchain::None:
|
||||
default:
|
||||
return Utils::Id();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
namespace Deprecated {
|
||||
namespace Toolchain {
|
||||
QString languageId(Language l)
|
||||
{
|
||||
switch (l) {
|
||||
case Language::None:
|
||||
return QStringLiteral("None");
|
||||
case Language::C:
|
||||
return QStringLiteral("C");
|
||||
case Language::Cxx:
|
||||
return QStringLiteral("Cxx");
|
||||
};
|
||||
return QString();
|
||||
}
|
||||
} // namespace Toolchain
|
||||
} // namespace Deprecated
|
||||
|
||||
/*!
|
||||
\class ProjectExplorer::ToolChain
|
||||
@@ -219,6 +253,15 @@ QVariantMap ToolChain::toMap() const
|
||||
result.insert(QLatin1String(ID_KEY), idToSave);
|
||||
result.insert(QLatin1String(DISPLAY_NAME_KEY), displayName());
|
||||
result.insert(QLatin1String(AUTODETECT_KEY), isAutoDetected());
|
||||
// <Compatibility with QtC 4.2>
|
||||
int oldLanguageId = -1;
|
||||
if (language() == ProjectExplorer::Constants::C_LANGUAGE_ID)
|
||||
oldLanguageId = 1;
|
||||
else if (language() == ProjectExplorer::Constants::CXX_LANGUAGE_ID)
|
||||
oldLanguageId = 2;
|
||||
if (oldLanguageId >= 0)
|
||||
result.insert(LANGUAGE_KEY_V1, oldLanguageId);
|
||||
// </Compatibility>
|
||||
result.insert(QLatin1String(LANGUAGE_KEY_V2), language().toSetting());
|
||||
if (!d->m_targetAbiKey.isEmpty())
|
||||
result.insert(d->m_targetAbiKey, d->m_targetAbi.toString());
|
||||
@@ -328,6 +371,8 @@ bool ToolChain::fromMap(const QVariantMap &data)
|
||||
d->m_language = Utils::Id::fromString(langId.mid(pos + 1));
|
||||
else
|
||||
d->m_language = Utils::Id::fromString(langId);
|
||||
} else if (data.contains(LANGUAGE_KEY_V1)) { // Import from old settings
|
||||
d->m_language = Internal::fromLanguageV1(data.value(QLatin1String(LANGUAGE_KEY_V1)).toInt());
|
||||
}
|
||||
|
||||
if (!d->m_language.isValid())
|
||||
|
||||
Reference in New Issue
Block a user