f4exb / sdrangel

SDR Rx/Tx software for Airspy, Airspy HF+, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay and FunCube
GNU General Public License v3.0
2.87k stars 435 forks source link

Fix saving configurations after deleting some entries #2109

Closed dforsi closed 4 months ago

dforsi commented 4 months ago

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 and configuration-2 and you deleted one of them (it doesn't matter which one) the old configuration-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.