Skip to content

Commit

Permalink
- Attempt to read settings before showing dialog.
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed Aug 16, 2024
1 parent 94fcee5 commit b8e2342
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
9 changes: 4 additions & 5 deletions cube/swiss/source/config/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1090,10 +1090,11 @@ void config_find(ConfigEntry *entry) {
Returns 1 on successful file open, 0 otherwise
*/
int config_init(void (*progress_indicator)(char*, int, int)) {
int res = 0;
progress_indicator("Loading settings", 1, -2);
if(!config_set_device()) {
progress_indicator(NULL, 0, 0);
return 0;
return res;
}

// Make the new settings base dir(s) if we don't have them already
Expand All @@ -1116,9 +1117,7 @@ int config_init(void (*progress_indicator)(char*, int, int)) {
if(configData != NULL) {
config_parse_global(configData);
free(configData);
} else {
// Store current/defaults.
config_update_global(false);
res = 1;
}

// Read the recent list if enabled
Expand All @@ -1132,7 +1131,7 @@ int config_init(void (*progress_indicator)(char*, int, int)) {
}
progress_indicator(NULL, 0, 0);
config_unset_device();
return 0;
return res;
}

SwissSettings backup;
Expand Down
13 changes: 8 additions & 5 deletions cube/swiss/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,23 @@ int main(int argc, char *argv[])
// Scan here since some devices would already be initialised (faster)
populateDeviceAvailability();

// Read Swiss settings
if(!config_init(&config_migration)) {
swissSettings.configDeviceId = DEVICE_ID_UNK;
}
// If there's no default config device, set it to the first writable device available
if(swissSettings.configDeviceId == DEVICE_ID_UNK) {
for(int i = 0; i < MAX_DEVICES; i++) {
for(i = 0; i < MAX_DEVICES; i++) {
if(allDevices[i] != NULL && (allDevices[i]->features & FEAT_CONFIG_DEVICE) && deviceHandler_getDeviceAvailable(allDevices[i])) {
swissSettings.configDeviceId = allDevices[i]->deviceUniqueId;
print_gecko("No default config device found, using [%s]\r\n", allDevices[i]->deviceName);
show_settings(PAGE_GLOBAL, SET_CONFIG_DEV, NULL);
if(!config_init(&config_migration)) {
show_settings(PAGE_GLOBAL, SET_CONFIG_DEV, NULL);
}
break;
}
}
}

// Read Swiss settings
config_init(&config_migration);
config_parse_args(argc, argv);

// Swiss video mode force
Expand Down

0 comments on commit b8e2342

Please sign in to comment.