fixed bug with settings fucking up units that were already loaded

sipo
Ondřej Hruška 6 years ago
parent 05875a8167
commit c4cc3bb9ce
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 16
      framework/settings.c
  2. 2
      framework/system_settings.h

@ -293,7 +293,7 @@ void settings_build_pinout_txt(IniWriter *iw)
void settings_load_ini_begin(void) void settings_load_ini_begin(void)
{ {
SystemSettings.modified = true; 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) 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. // Init functions are run for first key in the section.
if (streq(section, "SYSTEM")) { if (streq(section, "SYSTEM")) {
if (SystemSettings.loading_inifile == 0) {
if (SystemSettings.pristine) { SystemSettings.loading_inifile = 'S';
SystemSettings.pristine = false;
systemsettings_loadDefaults(); systemsettings_loadDefaults();
} }
@ -316,8 +315,8 @@ void settings_load_ini_key(const char *restrict section, const char *restrict ke
} }
else if (streq(section, "UNITS")) { else if (streq(section, "UNITS")) {
if (SystemSettings.pristine) { if (SystemSettings.loading_inifile == 0) {
SystemSettings.pristine = false; SystemSettings.loading_inifile = 'U';
ureg_remove_all_units(); 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) void settings_load_ini_end(void)
{ {
if (!ureg_finalize_all_init()) { if (SystemSettings.loading_inifile == 'U') {
dbg("Some units failed to init!!"); bool suc = ureg_finalize_all_init();
if (!suc) dbg("Some units failed to init!!");
} }
} }

@ -17,7 +17,7 @@ struct system_settings {
// Support flags put here for scoping, but not atcually part of the persistent 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 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 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; extern struct system_settings SystemSettings;

Loading…
Cancel
Save