diff --git a/WINGs/WINGs/WINGs.h b/WINGs/WINGs/WINGs.h index d3b4f285..7149aeb6 100644 --- a/WINGs/WINGs/WINGs.h +++ b/WINGs/WINGs/WINGs.h @@ -642,9 +642,11 @@ WMRect wmkrect(int x, int y, unsigned int width, unsigned int height); /* ---[ WINGs/wapplication.c ]-------------------------------------------- */ - void WMInitializeApplication(const char *applicationName, int *argc, char **argv); +/* You're supposed to call this funtion before exiting so WINGs can terminate properly */ +void WMReleaseApplication(void); + void WMSetResourcePath(const char *path); /* don't free the returned string */ diff --git a/WINGs/WINGs/WINGsP.h b/WINGs/WINGs/WINGsP.h index de014124..5a6e6126 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 ada942fe..b1b37128 100644 --- a/WINGs/notification.c +++ b/WINGs/notification.c @@ -94,6 +94,21 @@ void W_InitNotificationCenter(void) notificationCenter->observerTable = WMCreateHashTable(WMIntHashCallbacks); } +void W_ReleaseNotificationCenter(void) +{ + 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 WMAddNotificationObserver(WMNotificationObserverAction * observerAction, void *observer, const char *name, void *object) diff --git a/WINGs/wapplication.c b/WINGs/wapplication.c index a0aec2e1..beca03d9 100644 --- a/WINGs/wapplication.c +++ b/WINGs/wapplication.c @@ -48,6 +48,21 @@ void WMInitializeApplication(const char *applicationName, int *argc, char **argv W_InitNotificationCenter(); } +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); +} + void WMSetResourcePath(const char *path) { if (WMApplication.resourcePath)