1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-31 11:02:35 +01:00

WINGs: Fix crash on exit while trying to save user config changes

Recent patches has introduced the ability to exit cleanly from the WINGs
library, but this introduced some side effects because a function is
registered with 'atexit' to save user config on exit, which may not work
anymore because WMReleaseApplication frees some stuff needed for that task.

This patch handles this so that both method works, in case user of the lib
would forget to call the clean exit function.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2014-05-09 09:45:27 +02:00
committed by Carlos R. Mafra
parent 1b2e8a6491
commit a2328d9842
4 changed files with 60 additions and 3 deletions

View File

@@ -10,6 +10,9 @@
#include "wconfig.h"
#include "WINGs.h"
#include "WINGsP.h"
#include "userdefaults.h"
typedef struct W_UserDefaults {
WMPropList *defaults;
@@ -114,9 +117,19 @@ char *wglobaldefaultspathfordomain(const char *domain)
return t;
}
static void
saveDefaultsChanges(void)
void w_save_defaults_changes(void)
{
if (WMApplication.applicationName == NULL) {
/*
* This means that the user has properly exited by calling the
* function 'WMReleaseApplication' (which has already called us)
* but we're being called again by the fallback 'atexit' method
* (the legacy way of saving changes on exit which is kept for
* application that would forget to call 'WMReleaseApplication')
*/
return;
}
/* save the user defaults databases */
synchronizeUserDefaults(NULL);
}
@@ -127,7 +140,7 @@ static void registerSaveOnExit(void)
static Bool registeredSaveOnExit = False;
if (!registeredSaveOnExit) {
atexit(saveDefaultsChanges);
atexit(w_save_defaults_changes);
registeredSaveOnExit = True;
}
}