From 78c39850ae576188fb5d0329a1aa7a1cd14368b3 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 9 Mar 2019 13:00:59 +0100 Subject: [PATCH] Fixed: Check profile details in backup profiles if deleted --HG-- branch : develop --- .../tools/client/ryzom_installer/src/configfile.cpp | 10 ++++++++++ .../tools/client/ryzom_installer/src/configfile.h | 1 + .../client/ryzom_installer/src/operationdialog.cpp | 13 ++++++++++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index d23119b27..7b61bda7e 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -264,6 +264,16 @@ const CServer& CConfigFile::getServer(const QString &id) const return getServer(); } +CProfile CConfigFile::getBackupProfile(const QString &id) const +{ + for (int i = 0; i < m_backupProfiles.size(); ++i) + { + if (m_backupProfiles[i].id == id) return m_backupProfiles[i]; + } + + return NoProfile; +} + void CConfigFile::backupProfiles() { m_backupProfiles = m_profiles; diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.h b/code/ryzom/tools/client/ryzom_installer/src/configfile.h index baa815bd8..6480c1f87 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.h +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.h @@ -53,6 +53,7 @@ public: void setProfiles(const CProfiles &profiles) { m_profiles = profiles; } CProfiles getBackupProfiles() const { return m_backupProfiles; } + CProfile getBackupProfile(const QString &id) const; void backupProfiles(); QString getLanguage() const { return m_language; } diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp index e9d6fdebd..fe01509ab 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp @@ -1105,6 +1105,9 @@ void COperationDialog::deleteComponentsProfiles() CConfigFile *config = CConfigFile::getInstance(); + // some profiles have been removed, use backup profiles + bool useBackup = !config->getBackupProfiles().isEmpty(); + int i = 0; foreach(const QString &profileId, m_removeComponents.profiles) @@ -1115,7 +1118,11 @@ void COperationDialog::deleteComponentsProfiles() return; } - const CProfile &profile = config->getProfile(profileId); + // only search in backup profiles, because they are already deleted in profiles + const CProfile &profile = useBackup ? config->getBackupProfile(profileId):config->getProfile(profileId); + + // already deleted profile + if (profile.id.isEmpty()) continue; emit progress(i++, profile.name); @@ -1134,8 +1141,8 @@ void COperationDialog::deleteComponentsProfiles() profile.deleteShortcuts(); - // delete profile - config->removeProfile(profileId); + // delete profile if still used + if (!useBackup) config->removeProfile(profileId); } emit success(m_removeComponents.profiles.size());