Fixed: Check profile details in backup profiles if deleted

--HG--
branch : develop
feature/pipeline-tools
kervala 6 years ago
parent 21f15a47bc
commit 78c39850ae

@ -264,6 +264,16 @@ const CServer& CConfigFile::getServer(const QString &id) const
return getServer(); 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() void CConfigFile::backupProfiles()
{ {
m_backupProfiles = m_profiles; m_backupProfiles = m_profiles;

@ -53,6 +53,7 @@ public:
void setProfiles(const CProfiles &profiles) { m_profiles = profiles; } void setProfiles(const CProfiles &profiles) { m_profiles = profiles; }
CProfiles getBackupProfiles() const { return m_backupProfiles; } CProfiles getBackupProfiles() const { return m_backupProfiles; }
CProfile getBackupProfile(const QString &id) const;
void backupProfiles(); void backupProfiles();
QString getLanguage() const { return m_language; } QString getLanguage() const { return m_language; }

@ -1105,6 +1105,9 @@ void COperationDialog::deleteComponentsProfiles()
CConfigFile *config = CConfigFile::getInstance(); CConfigFile *config = CConfigFile::getInstance();
// some profiles have been removed, use backup profiles
bool useBackup = !config->getBackupProfiles().isEmpty();
int i = 0; int i = 0;
foreach(const QString &profileId, m_removeComponents.profiles) foreach(const QString &profileId, m_removeComponents.profiles)
@ -1115,7 +1118,11 @@ void COperationDialog::deleteComponentsProfiles()
return; 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); emit progress(i++, profile.name);
@ -1134,8 +1141,8 @@ void COperationDialog::deleteComponentsProfiles()
profile.deleteShortcuts(); profile.deleteShortcuts();
// delete profile // delete profile if still used
config->removeProfile(profileId); if (!useBackup) config->removeProfile(profileId);
} }
emit success(m_removeComponents.profiles.size()); emit success(m_removeComponents.profiles.size());

Loading…
Cancel
Save