[devhelp] App: destroy all GtkWindows for the quit GAction
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] App: destroy all GtkWindows for the quit GAction
- Date: Thu, 28 Dec 2017 20:46:38 +0000 (UTC)
commit 23e09a0134af9772de86a9adc2d1815d14d0118d
Author: Sébastien Wilmet <swilmet gnome org>
Date: Thu Dec 28 21:00:44 2017 +0100
App: destroy all GtkWindows for the quit GAction
src/dh-app.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/dh-app.c b/src/dh-app.c
index 56ac945..228bfc9 100644
--- a/src/dh-app.c
+++ b/src/dh-app.c
@@ -96,9 +96,17 @@ quit_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
- DhApp *app = DH_APP (user_data);
+ GtkApplication *app = GTK_APPLICATION (user_data);
+ GList *windows;
- g_application_quit (G_APPLICATION (app));
+ /* Do not call g_application_quit(). If g_application_quit() is called
+ * the GtkWindows are not finalized. A GtkWindow subclass may want to
+ * save some GSettings when the window is closed, so it's better to
+ * properly close all the windows. And it's also more friendly to memory
+ * debugging tools.
+ */
+ while ((windows = gtk_application_get_windows (app)) != NULL)
+ gtk_widget_destroy (GTK_WIDGET (windows->data));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]