diff options
author | Tobias Hunger <tobias.hunger@digia.com> | 2012-10-04 13:52:47 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@digia.com> | 2012-10-04 15:19:25 +0200 |
commit | bec84f09aa6260b28093953a424de33c5a81a40b (patch) | |
tree | db44fdbe0668fd9e7a3257c21cda32251fa88eca | |
parent | 9a9443273ee57cae5bc4b831ee5b9b2db9180a3a (diff) | |
download | qt-creator-bec84f09aa6260b28093953a424de33c5a81a40b.tar.gz |
Backup foreign .user files before overwriting them
At the very least data can be restored that way.
Change-Id: I3a75783f9988fee7cd3571ed6e57c3cc0c86e0e8
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
-rw-r--r-- | src/plugins/projectexplorer/settingsaccessor.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/plugins/projectexplorer/settingsaccessor.cpp b/src/plugins/projectexplorer/settingsaccessor.cpp index b5c553f2b8..8e854c6bfd 100644 --- a/src/plugins/projectexplorer/settingsaccessor.cpp +++ b/src/plugins/projectexplorer/settingsaccessor.cpp @@ -622,7 +622,12 @@ QVariantMap SettingsAccessor::restoreSettings() const } // Verify environment. - if (!verifyEnvironmentId(settings.m_map.value(QLatin1String(ENVIRONMENT_ID_KEY)).toString())) { + const QString fileId = settings.m_map.value(QLatin1String(ENVIRONMENT_ID_KEY)).toString(); + const QString creatorId = ProjectExplorerPlugin::instance()->projectExplorerSettings().environmentId.toString(); + if (fileId.isEmpty() || fileId != creatorId) { + QString backup = fn + QLatin1Char('.') + fileId.mid(1, 7); + QFile::copy(fn, backup); + // TODO tr, casing check QMessageBox msgBox( QMessageBox::Question, @@ -777,17 +782,6 @@ void SettingsAccessor::addVersionHandler(UserFileVersionHandler *handler) Q_ASSERT(m_handlers.contains(i)); } -bool SettingsAccessor::verifyEnvironmentId(const QString &id) -{ - QUuid fileEnvironmentId(id); - if (!fileEnvironmentId.isNull() - && fileEnvironmentId - != ProjectExplorerPlugin::instance()->projectExplorerSettings().environmentId) { - return false; - } - return true; -} - // ------------------------------------------------------------------------- // SettingsData // ------------------------------------------------------------------------- |