summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorPhil Jones <philj56@gmail.com>2021-11-01 16:06:51 +0000
committerPhil Jones <philj56@gmail.com>2021-11-01 16:06:51 +0000
commit94fa998b7e3524ce101a977ed3516fac13461287 (patch)
tree0d4fae990021e876f7ad2deb7fbabc29a99804a4 /src/main.c
parentf31976da251ca59ed7edb406379c12edf817711e (diff)
Add extra cleanup code to debug builds.
Also fix some memory leaks.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index 0cd266a..7799653 100644
--- a/src/main.c
+++ b/src/main.c
@@ -830,10 +830,43 @@ int main(int argc, char *argv[])
}
}
- log_info("Window closed, performing cleanup.\n");
+ log_debug("Window closed, performing cleanup.\n");
+#ifdef DEBUG
+ /*
+ * For debug builds, try to cleanup as much as possible, to make using
+ * e.g. Valgrind easier. There's still a few unavoidable leaks though,
+ * mostly from OpenGL libs and Pango.
+ */
+ entry_destroy(&state.window.entry);
+ surface_destroy(&state.window.entry.surface);
+ surface_destroy(&state.window.surface);
+ if (state.window.background_image.buffer != NULL) {
+ free(state.window.background_image.buffer);
+ state.window.background_image.buffer = NULL;
+ }
+ eglTerminate(state.window.surface.egl.display);
+ wl_subsurface_destroy(state.window.entry.wl_subsurface);
+ wl_surface_destroy(state.window.entry.surface.wl_surface);
+ xdg_toplevel_destroy(state.window.xdg_toplevel);
+ xdg_surface_destroy(state.window.xdg_surface);
+ wl_surface_destroy(state.window.surface.wl_surface);
+ wl_keyboard_release(state.wl_keyboard);
+ wl_compositor_destroy(state.wl_compositor);
+ wl_subcompositor_destroy(state.wl_subcompositor);
+ wl_seat_release(state.wl_seat);
+ wl_output_release(state.wl_output);
+ xdg_wm_base_destroy(state.xdg_wm_base);
+ xkb_state_unref(state.xkb_state);
+ xkb_keymap_unref(state.xkb_keymap);
+ xkb_context_unref(state.xkb_context);
+ wl_registry_destroy(state.wl_registry);
+#endif
+ /*
+ * For release builds, skip straight to display disconnection and quit.
+ */
wl_display_disconnect(state.wl_display);
- log_info("Finished, exiting.\n");
+ log_debug("Finished, exiting.\n");
return 0;
}