Also update engine list when saving engine settings
authorH.G.Muller <hgm@hgm-xboard.(none)>
Sun, 29 Oct 2017 21:20:48 +0000 (22:20 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Sun, 29 Oct 2017 21:20:48 +0000 (22:20 +0100)
The 'Make Persistent' button in the Engine Settings dialog will now
also cause the -engineList file to be read before being processed,
and be written back after it, to keep the list up to date for all
open XBoard instances. There still is a problem here, that when another
instance has changed settings of the currently loaded engine, this engine
is no longerrecognized as being in the list. But at least the user will
be warned in such a case that makig the settings change persistent has
failed.

backend.c

index 43d9b1f..e5c7f72 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -11401,6 +11401,7 @@ SaveEngineSettings (int n)
 {
     int len; char *p, *q, *s, buf[MSG_SIZ], *optionSettings;
     if(!currentEngine[n] || !currentEngine[n][0]) { DisplayMessage("saving failed: engine not from list", ""); return; } // no engine from list is loaded
+    if(*engineListFile) ParseSettingsFile(engineListFile, &engineListFile); // update engine list
     p = strstr(firstChessProgramNames, currentEngine[n]);
     if(!p) { DisplayMessage("saving failed: engine not found in list", ""); return; } // sanity check; engine could be deleted from list after loading
     optionSettings = ResendOptions(n ? &second : &first, FALSE);
@@ -11420,6 +11421,7 @@ SaveEngineSettings (int n)
     s = malloc(len);
     snprintf(s, len, "%s%s%s", firstChessProgramNames, currentEngine[n], q);
     FREE(firstChessProgramNames); firstChessProgramNames = s; // new list
+    if(*engineListFile) SaveEngineList();
 }
 
 // following implemented as macro to avoid type limitations