[almanah] core: Don't double-free the main window on exiting



commit 12bdc2f7d2a9a7049c958285be6564f64aa45fe4
Author: Philip Withnall <philip tecnocode co uk>
Date:   Mon Apr 18 17:52:55 2011 +0100

    core: Don't double-free the main window on exiting

 src/application.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/src/application.c b/src/application.c
index 89a6dc3..bdc83a8 100644
--- a/src/application.c
+++ b/src/application.c
@@ -213,6 +213,14 @@ startup (GApplication *application)
 	priv->event_manager = almanah_event_manager_new ();
 }
 
+/* Nullify our pointer to the main window when it gets destroyed (e.g. when we quit) so that we don't then try
+ * to destroy it again in dispose(). */
+static void
+main_window_destroy_cb (AlmanahMainWindow *main_window, AlmanahApplication *self)
+{
+	self->priv->main_window = NULL;
+}
+
 static void
 activate (GApplication *application)
 {
@@ -223,6 +231,7 @@ activate (GApplication *application)
 	if (priv->main_window == NULL) {
 		priv->main_window = almanah_main_window_new (self);
 		gtk_widget_show_all (GTK_WIDGET (priv->main_window));
+		g_signal_connect (priv->main_window, "destroy", (GCallback) main_window_destroy_cb, application);
 	}
 
 	/* Bring it to the foreground */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]