From: Christophe CURIS <christophe.cu...@free.fr> - made the prototype correct in the public API, with a comment for potential users (because we donc have a doc yet);
- added the missing prototype for the internal NotificationCenter cleanup function; - fixed possible crash(s) on release of notification center for NULL pointer issues; - in WMReleaseApplication, release internal app info at the end in case the previous cleanup function might use them; - in WPrefs, moved WMReleaseApplication call to the right place; - added call to WMReleaseApplication in wmagnify app too; - in wmsetbg's new check, report a Warning instead of an Error if nice failed, as it is not preventin app from continuing Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> --- WINGs/WINGs/WINGs.h | 3 ++- WINGs/WINGs/WINGsP.h | 2 ++ WINGs/notification.c | 19 +++++++++++-------- WINGs/wapplication.c | 10 +++++++--- WPrefs.app/TexturePanel.c | 1 - WPrefs.app/WPrefs.c | 1 + util/wmagnify.c | 1 + util/wmsetbg.c | 10 +++++++--- 8 files changed, 31 insertions(+), 16 deletions(-) diff --git a/WINGs/WINGs/WINGs.h b/WINGs/WINGs/WINGs.h index 6b1f6b6..dd3fac5 100644 --- a/WINGs/WINGs/WINGs.h +++ b/WINGs/WINGs/WINGs.h @@ -644,7 +644,8 @@ WMRect wmkrect(int x, int y, unsigned int width, unsigned int height); void WMInitializeApplication(const char *applicationName, int *argc, char **argv); -void WMReleaseApplication(); +/* You're supposed to call this funtion before exiting so WINGs can terminate properly */ +void WMReleaseApplication(void); void WMSetResourcePath(const char *path); diff --git a/WINGs/WINGs/WINGsP.h b/WINGs/WINGs/WINGsP.h index de01412..5a6e612 100644 --- a/WINGs/WINGs/WINGsP.h +++ b/WINGs/WINGs/WINGsP.h @@ -365,6 +365,8 @@ Bool W_HandleInputEvents(Bool waitForInput, int inputfd); void W_InitNotificationCenter(void); +void W_ReleaseNotificationCenter(void); + void W_FlushASAPNotificationQueue(void); void W_FlushIdleNotificationQueue(void); diff --git a/WINGs/notification.c b/WINGs/notification.c index ebb05ec..b1b3712 100644 --- a/WINGs/notification.c +++ b/WINGs/notification.c @@ -94,16 +94,19 @@ void W_InitNotificationCenter(void) notificationCenter->observerTable = WMCreateHashTable(WMIntHashCallbacks); } -void WMReleaseNotificationCenter() +void W_ReleaseNotificationCenter(void) { - if (notificationCenter->nameTable) - WMFreeHashTable(notificationCenter->nameTable); - if (notificationCenter->objectTable) - WMFreeHashTable(notificationCenter->objectTable); - if (notificationCenter->observerTable) - WMFreeHashTable(notificationCenter->observerTable); - if (notificationCenter) + if (notificationCenter) { + if (notificationCenter->nameTable) + WMFreeHashTable(notificationCenter->nameTable); + if (notificationCenter->objectTable) + WMFreeHashTable(notificationCenter->objectTable); + if (notificationCenter->observerTable) + WMFreeHashTable(notificationCenter->observerTable); + wfree(notificationCenter); + notificationCenter = NULL; + } } void diff --git a/WINGs/wapplication.c b/WINGs/wapplication.c index 84ede06..beca03d 100644 --- a/WINGs/wapplication.c +++ b/WINGs/wapplication.c @@ -48,15 +48,19 @@ void WMInitializeApplication(const char *applicationName, int *argc, char **argv W_InitNotificationCenter(); } -void WMReleaseApplication() { - int i =0; +void WMReleaseApplication(void) { + int i; + + W_ReleaseNotificationCenter(); + if (WMApplication.applicationName) wfree(WMApplication.applicationName); + for (i = 0; i < WMApplication.argc; i++) wfree(WMApplication.argv[i]); + if (WMApplication.argv) wfree(WMApplication.argv); - WMReleaseNotificationCenter(); } void WMSetResourcePath(const char *path) diff --git a/WPrefs.app/TexturePanel.c b/WPrefs.app/TexturePanel.c index 530c124..9f2b86a 100644 --- a/WPrefs.app/TexturePanel.c +++ b/WPrefs.app/TexturePanel.c @@ -1527,7 +1527,6 @@ int main(int argc, char **argv) ShowTexturePanel(panel); WMScreenMainLoop(scr); - WMReleaseApplication(); return 0; } #endif diff --git a/WPrefs.app/WPrefs.c b/WPrefs.app/WPrefs.c index 31192aa..c3274ee 100644 --- a/WPrefs.app/WPrefs.c +++ b/WPrefs.app/WPrefs.c @@ -84,6 +84,7 @@ static noreturn void quit(WMWidget *w, void *data) prepareForClose(); + WMReleaseApplication(); exit(0); } diff --git a/util/wmagnify.c b/util/wmagnify.c index f310bc7..03f4ec0 100644 --- a/util/wmagnify.c +++ b/util/wmagnify.c @@ -292,6 +292,7 @@ static void closeWindow(WMWidget * w, void *d) windowCount--; if (windowCount == 0) { + WMReleaseApplication(); exit(0); } else { WMDeleteTimerHandler(data->tid); diff --git a/util/wmsetbg.c b/util/wmsetbg.c index d85eb43..ee4780f 100644 --- a/util/wmsetbg.c +++ b/util/wmsetbg.c @@ -990,14 +990,16 @@ static noreturn void helperLoop(RContext * rc) static void updateDomain(const char *domain, const char *key, const char *texture) { + int result; char *program = "wdwrite"; /* here is a mem leak */ - int result = system(wstrconcat("wdwrite ", + result = system(wstrconcat("wdwrite ", wstrconcat(domain, smooth ? " SmoothWorkspaceBack YES" : " SmoothWorkspaceBack NO"))); if (result == -1) werror("error executing system command"); + execlp(program, program, domain, key, texture, NULL); wwarning("warning could not run \"%s\"", program); } @@ -1379,10 +1381,12 @@ int main(int argc, char **argv) } if (helperMode) { + int result; + /* lower priority, so that it wont use all the CPU */ - int result = nice(15); + result = nice(15); if (result == -1) - werror("error could not nice process"); + wwarning("error could not nice process"); helperLoop(rc); } else { -- 1.8.5.3 -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.