forked from qt-creator/qt-creator
SettingsAccessor: Move handling of environment Id into file accessor
Change-Id: I0712358cce12066bc5dd91c00ca387c050644150 Reviewed-by: Daniel Teske <daniel.teske@digia.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -120,8 +120,6 @@ using Utils::PersistentSettingsWriter;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const char VERSION_KEY[] = "ProjectExplorer.Project.Updater.FileVersion";
|
|
||||||
const char ENVIRONMENT_ID_KEY[] = "ProjectExplorer.Project.Updater.EnvironmentId";
|
|
||||||
const char USER_STICKY_KEYS_KEY[] = "ProjectExplorer.Project.UserStickyKeys";
|
const char USER_STICKY_KEYS_KEY[] = "ProjectExplorer.Project.UserStickyKeys";
|
||||||
|
|
||||||
const char SHARED_SETTINGS[] = "SharedSettings";
|
const char SHARED_SETTINGS[] = "SharedSettings";
|
||||||
@@ -624,10 +622,10 @@ QVariantMap SettingsAccessor::restoreSettings() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify environment.
|
// Verify environment.
|
||||||
const QString fileId = settings.m_map.value(QLatin1String(ENVIRONMENT_ID_KEY)).toString();
|
const QByteArray fileId = settings.environmentId();
|
||||||
const QString creatorId = ProjectExplorerPlugin::instance()->projectExplorerSettings().environmentId.toString();
|
const QByteArray creatorId = ProjectExplorerPlugin::instance()->projectExplorerSettings().environmentId.toByteArray();
|
||||||
if (fileId.isEmpty() || fileId != creatorId) {
|
if (fileId.isEmpty() || fileId != creatorId) {
|
||||||
QString backup = fn + QLatin1Char('.') + fileId.mid(1, 7);
|
QString backup = fn + QLatin1Char('.') + QString::fromLatin1(fileId).mid(1, 7);
|
||||||
QFile::copy(fn, backup);
|
QFile::copy(fn, backup);
|
||||||
|
|
||||||
if (!fileId.isEmpty()) {
|
if (!fileId.isEmpty()) {
|
||||||
@@ -793,6 +791,7 @@ void SettingsAccessor::SettingsData::clear()
|
|||||||
m_usingBackup = false;
|
m_usingBackup = false;
|
||||||
m_map.clear();
|
m_map.clear();
|
||||||
m_fileName.clear();
|
m_fileName.clear();
|
||||||
|
m_environmentId.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SettingsAccessor::SettingsData::isValid() const
|
bool SettingsAccessor::SettingsData::isValid() const
|
||||||
@@ -803,6 +802,10 @@ bool SettingsAccessor::SettingsData::isValid() const
|
|||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// FileAcessor
|
// FileAcessor
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static const char VERSION_KEY[] = "ProjectExplorer.Project.Updater.FileVersion";
|
||||||
|
static const char ENVIRONMENT_ID_KEY[] = "ProjectExplorer.Project.Updater.EnvironmentId";
|
||||||
|
|
||||||
SettingsAccessor::FileAccessor::FileAccessor(const QByteArray &id,
|
SettingsAccessor::FileAccessor::FileAccessor(const QByteArray &id,
|
||||||
const QString &defaultSuffix,
|
const QString &defaultSuffix,
|
||||||
const QString &environmentSuffix,
|
const QString &environmentSuffix,
|
||||||
@@ -906,6 +909,12 @@ bool SettingsAccessor::FileAccessor::readFile(SettingsData *settings) const
|
|||||||
|
|
||||||
settings->m_map = reader.restoreValues();
|
settings->m_map = reader.restoreValues();
|
||||||
|
|
||||||
|
// Get environment Id:
|
||||||
|
if (m_environmentSpecific) {
|
||||||
|
settings->m_environmentId = settings->m_map.value(QLatin1String(ENVIRONMENT_ID_KEY)).toByteArray();
|
||||||
|
settings->m_map.remove(QLatin1String(ENVIRONMENT_ID_KEY));
|
||||||
|
}
|
||||||
|
|
||||||
// Get and verify file version
|
// Get and verify file version
|
||||||
settings->m_version = settings->m_map.value(QLatin1String(VERSION_KEY), 0).toInt();
|
settings->m_version = settings->m_map.value(QLatin1String(VERSION_KEY), 0).toInt();
|
||||||
if (!m_versionStrict)
|
if (!m_versionStrict)
|
||||||
|
@@ -69,8 +69,10 @@ private:
|
|||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
QByteArray environmentId() const { return m_environmentId; }
|
||||||
|
|
||||||
int m_version;
|
int m_version;
|
||||||
|
QByteArray m_environmentId;
|
||||||
bool m_usingBackup;
|
bool m_usingBackup;
|
||||||
QVariantMap m_map;
|
QVariantMap m_map;
|
||||||
Utils::FileName m_fileName;
|
Utils::FileName m_fileName;
|
||||||
|
Reference in New Issue
Block a user