diff options
author | Jess VanDerwalker <washu@sonic.net> | 2012-04-24 09:52:51 -0700 |
---|---|---|
committer | Jess VanDerwalker <washu@sonic.net> | 2012-04-25 14:51:02 -0700 |
commit | 6a93df24799d563e15dba2944985234f28ba4320 (patch) | |
tree | d9c4c0bfe163b52d5d34d0913ecd884ac79d5a6a /src | |
parent | f83c72e3d6c6b04ea1db9ca6a8e0e260a527a0ee (diff) |
Memory for window freed in _xcwm_window_release.
Memory for the window allocated by library is freed in
_xcwm_window_release, which is called after the client has done any
clean up it needs to do on its side.
Signed-off-by: Jess VanDerwalker <washu@sonic.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libxcwm/event_loop.c | 12 | ||||
-rw-r--r-- | src/libxcwm/window.c | 17 | ||||
-rw-r--r-- | src/libxcwm/xcwm_internal.h | 10 | ||||
-rw-r--r-- | src/xtoq/XtoqController.m | 49 |
4 files changed, 51 insertions, 37 deletions
diff --git a/src/libxcwm/event_loop.c b/src/libxcwm/event_loop.c index fd5afb6..60cc65d 100644 --- a/src/libxcwm/event_loop.c +++ b/src/libxcwm/event_loop.c @@ -253,15 +253,9 @@ run_event_loop(void *thread_arg_struct) return_evt->window = window; callback_ptr(return_evt); - /* FIXME: Should rework how windows are destroyed, - * since its not making sense to do memory clean up - * here. */ - free(window->bounds); - free(window->dmg_bounds); - if (window->name) { - free(window->name); - } - free(window); + + // Release memory for the window + _xcwm_window_release(window); break; } diff --git a/src/libxcwm/window.c b/src/libxcwm/window.c index 34a7409..e576b4f 100644 --- a/src/libxcwm/window.c +++ b/src/libxcwm/window.c @@ -269,6 +269,23 @@ xcwm_window_request_close(xcwm_window_t *window) return; } +void +_xcwm_window_release(xcwm_window_t *window) +{ + + if (!window) { + return; + } + + free(window->bounds); + if (window->dmg_bounds) { + free(window->dmg_bounds); + } + if (window->name) { + free(window->name); + } + free(window); +} /* Accessor functions into xcwm_window_t */ diff --git a/src/libxcwm/xcwm_internal.h b/src/libxcwm/xcwm_internal.h index 22900e8..8399226 100644 --- a/src/libxcwm/xcwm_internal.h +++ b/src/libxcwm/xcwm_internal.h @@ -252,6 +252,16 @@ _xcwm_destroy_window(xcb_connection_t *conn, xcb_destroy_notify_event_t *event); /** + * Release the window and free its memory. Call after client has done + * necessary clean up of the window on its side after the window has + * been closed and a XCWM_DESTROY event has been received for the + * window. + * @param window The window to release. + */ +void +_xcwm_window_release(xcwm_window_t *window); + +/** * Resize the window to given width and height. * @param conn The connection * @param window The id of window to resize diff --git a/src/xtoq/XtoqController.m b/src/xtoq/XtoqController.m index b7899a0..53da593 100644 --- a/src/xtoq/XtoqController.m +++ b/src/xtoq/XtoqController.m @@ -1,33 +1,26 @@ -/*Copyright (C) 2012 Aaron Skomra, Ben Huddle, Braden Wooley - - Permission is hereby granted, free of charge, to any person obtaining a copy of - this software and associated documentation files (the "Software"), to deal in - the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is furnished to do - so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +/* Copyright (C) 2012 Aaron Skomra, Ben Huddle, Braden Wooley + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, copy, + modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/** - * AppController.m - * xcwm - * - * - * This is the controller for the Popup to retreive the display number - * from the user. - */ - #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -497,7 +490,7 @@ - (void) destroyWindow:(xcwm_window_t *) window { // set the window to be closed - XtoqWindow *destWindow = xcwm_window_get_local_data(window); + XtoqWindow *destWindow = xcwm_window_get_local_data(window); //close window [destWindow close]; } |