fixed bug with settings fucking up units that were already loaded

This commit is contained in:
2018-01-14 00:27:34 +01:00
parent 05875a8167
commit c4cc3bb9ce
2 changed files with 9 additions and 9 deletions
+8 -8
View File
@@ -293,7 +293,7 @@ void settings_build_pinout_txt(IniWriter *iw)
void settings_load_ini_begin(void)
{
SystemSettings.modified = true;
SystemSettings.pristine = true;
SystemSettings.loading_inifile = 0;
}
void settings_load_ini_key(const char *restrict section, const char *restrict key, const char *restrict value)
@@ -305,9 +305,8 @@ void settings_load_ini_key(const char *restrict section, const char *restrict ke
// Init functions are run for first key in the section.
if (streq(section, "SYSTEM")) {
if (SystemSettings.pristine) {
SystemSettings.pristine = false;
if (SystemSettings.loading_inifile == 0) {
SystemSettings.loading_inifile = 'S';
systemsettings_loadDefaults();
}
@@ -316,8 +315,8 @@ void settings_load_ini_key(const char *restrict section, const char *restrict ke
}
else if (streq(section, "UNITS")) {
if (SystemSettings.pristine) {
SystemSettings.pristine = false;
if (SystemSettings.loading_inifile == 0) {
SystemSettings.loading_inifile = 'U';
ureg_remove_all_units();
}
@@ -347,7 +346,8 @@ void settings_load_ini_key(const char *restrict section, const char *restrict ke
void settings_load_ini_end(void)
{
if (!ureg_finalize_all_init()) {
dbg("Some units failed to init!!");
if (SystemSettings.loading_inifile == 'U') {
bool suc = ureg_finalize_all_init();
if (!suc) dbg("Some units failed to init!!");
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ struct system_settings {
// Support flags put here for scoping, but not atcually part of the persistent settings
volatile bool editable; //!< True if we booted with the LOCK jumper removed
volatile bool modified; //!< True if user did any change to the settings (checked when the LOCK jumper is replaced)
volatile bool pristine; //!< Marks unknown state before we reach first section marker that determines what file it is
volatile char loading_inifile; // S-system, U-units
};
extern struct system_settings SystemSettings;