Fix saving configurations after deleting some entries #2109
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR always deletes all configurations except "General" from the configuration file, otherwise when deleting at least one entry from a group the previous last entry wouldn't be deleted (at least on Linux which uses a .conf file with the ini format). For example if you had
configuration-1
andconfiguration-2
and you deleted one of them (it doesn't matter which one) the oldconfiguration-2
wouldn't get deleted.At this time the only group that doesn't end with a number is "General" and those which end with a number are:
$ grep startsWith sdrbase/settings/mainsettings.cpp
if (groups[i].startsWith("preset"))
else if (groups[i].startsWith("command"))
else if (groups[i].startsWith("featureset"))
else if (groups[i].startsWith("pluginpreset"))
else if (groups[i].startsWith("configuration"))
The simplest patch is to keep only "General" and delete everything else.
The pros are:
The cons are:
A more complicated approach would be storing a counter of how many entries were read from the configuration and delete only those exceeding the counter.