[eog] Fix broken application shutdown with new plugin system



commit 8b0acfddc52c220393770a9895b6b56cab7821fd
Author: Felix Riemann <friemann gnome org>
Date:   Sun Jan 2 22:27:10 2011 +0100

    Fix broken application shutdown with new plugin system
    
    The PeasExtensionSet was basically keeping a reference to the window
    preventing it from being destroyed correctly. Then the plugins leaked a
    reference to the window as well.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=626091

 plugins/fullscreen/eog-fullscreen-plugin.c         |   15 ++++++--
 plugins/reload/eog-reload-plugin.c                 |   15 ++++++--
 plugins/statusbar-date/eog-statusbar-date-plugin.c |   15 ++++++--
 src/eog-window.c                                   |   35 +++++++++----------
 4 files changed, 50 insertions(+), 30 deletions(-)
---
diff --git a/plugins/fullscreen/eog-fullscreen-plugin.c b/plugins/fullscreen/eog-fullscreen-plugin.c
index c9484bc..0aee28c 100644
--- a/plugins/fullscreen/eog-fullscreen-plugin.c
+++ b/plugins/fullscreen/eog-fullscreen-plugin.c
@@ -90,11 +90,18 @@ eog_fullscreen_plugin_init (EogFullscreenPlugin *plugin)
 }
 
 static void
-eog_fullscreen_plugin_finalize (GObject *object)
+eog_fullscreen_plugin_dispose (GObject *object)
 {
-	eog_debug_message (DEBUG_PLUGINS, "EogFullscreenPlugin finalizing");
+	EogFullscreenPlugin *plugin = EOG_FULLSCREEN_PLUGIN (object);
+
+	eog_debug_message (DEBUG_PLUGINS, "EogFullscreenPlugin disposing");
+
+	if (plugin->window != NULL) {
+		g_object_unref (plugin->window);
+		plugin->window = NULL;
+	}
 
-	G_OBJECT_CLASS (eog_fullscreen_plugin_parent_class)->finalize (object);
+	G_OBJECT_CLASS (eog_fullscreen_plugin_parent_class)->dispose (object);
 }
 
 static void
@@ -125,7 +132,7 @@ eog_fullscreen_plugin_class_init (EogFullscreenPluginClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-	object_class->finalize = eog_fullscreen_plugin_finalize;
+	object_class->dispose = eog_fullscreen_plugin_dispose;
 	object_class->set_property = eog_fullscreen_plugin_set_property;
 	object_class->get_property = eog_fullscreen_plugin_get_property;
 
diff --git a/plugins/reload/eog-reload-plugin.c b/plugins/reload/eog-reload-plugin.c
index 4b099f0..bd9d4d2 100644
--- a/plugins/reload/eog-reload-plugin.c
+++ b/plugins/reload/eog-reload-plugin.c
@@ -101,11 +101,18 @@ eog_reload_plugin_init (EogReloadPlugin *plugin)
 }
 
 static void
-eog_reload_plugin_finalize (GObject *object)
+eog_reload_plugin_dispose (GObject *object)
 {
-	eog_debug_message (DEBUG_PLUGINS, "EogReloadPlugin finalizing");
+	EogReloadPlugin *plugin = EOG_RELOAD_PLUGIN (object);
+
+	eog_debug_message (DEBUG_PLUGINS, "EogReloadPlugin disposing");
+
+	if (plugin->window != NULL) {
+		g_object_unref (plugin->window);
+		plugin->window = NULL;
+	}
 
-	G_OBJECT_CLASS (eog_reload_plugin_parent_class)->finalize (object);
+	G_OBJECT_CLASS (eog_reload_plugin_parent_class)->dispose (object);
 }
 
 static void
@@ -161,7 +168,7 @@ eog_reload_plugin_class_init (EogReloadPluginClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-	object_class->finalize = eog_reload_plugin_finalize;
+	object_class->dispose= eog_reload_plugin_dispose;
 	object_class->set_property = eog_reload_plugin_set_property;
 	object_class->get_property = eog_reload_plugin_get_property;
 
diff --git a/plugins/statusbar-date/eog-statusbar-date-plugin.c b/plugins/statusbar-date/eog-statusbar-date-plugin.c
index de72d07..ea12e5f 100644
--- a/plugins/statusbar-date/eog-statusbar-date-plugin.c
+++ b/plugins/statusbar-date/eog-statusbar-date-plugin.c
@@ -140,11 +140,18 @@ eog_statusbar_date_plugin_init (EogStatusbarDatePlugin *plugin)
 }
 
 static void
-eog_statusbar_date_plugin_finalize (GObject *object)
+eog_statusbar_date_plugin_dispose (GObject *object)
 {
-	eog_debug_message (DEBUG_PLUGINS, "EogStatusbarDatePlugin finalizing");
+	EogStatusbarDatePlugin *plugin = EOG_STATUSBAR_DATE_PLUGIN (object);
+
+	eog_debug_message (DEBUG_PLUGINS, "EogStatusbarDatePlugin disposing");
+
+	if (plugin->window != NULL) {
+		g_object_unref (plugin->window);
+		plugin->window = NULL;		
+	}
 
-	G_OBJECT_CLASS (eog_statusbar_date_plugin_parent_class)->finalize (object);
+	G_OBJECT_CLASS (eog_statusbar_date_plugin_parent_class)->dispose (object);
 }
 
 static void
@@ -190,7 +197,7 @@ eog_statusbar_date_plugin_class_init (EogStatusbarDatePluginClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-	object_class->finalize = eog_statusbar_date_plugin_finalize;
+	object_class->dispose = eog_statusbar_date_plugin_dispose;
 	object_class->set_property = eog_statusbar_date_plugin_set_property;
 	object_class->get_property = eog_statusbar_date_plugin_get_property;
 	
diff --git a/src/eog-window.c b/src/eog-window.c
index f334cb0..f28f1e2 100644
--- a/src/eog-window.c
+++ b/src/eog-window.c
@@ -184,6 +184,8 @@ struct _EogWindowPrivate {
 
 	GtkPageSetup        *page_setup;
 
+	PeasExtensionSet    *extensions;
+
 #ifdef HAVE_LCMS
         cmsHPROFILE         *display_profile;
 #endif
@@ -4595,6 +4597,12 @@ eog_window_dispose (GObject *object)
 
 	peas_engine_garbage_collect (PEAS_ENGINE (EOG_APP->plugin_engine));
 
+	if (priv->extensions != NULL) {
+		g_object_unref (priv->extensions);
+		priv->extensions = NULL;
+		peas_engine_garbage_collect (PEAS_ENGINE (EOG_APP->plugin_engine));
+	}
+
 	if (priv->store != NULL) {
 		g_signal_handlers_disconnect_by_func (priv->store,
 					      eog_window_list_store_image_added,
@@ -5072,38 +5080,29 @@ on_extension_removed (PeasExtensionSet *set,
 	peas_extension_call (exten, "deactivate", window);
 }
 
-static
-gboolean on_window_delete (GtkWidget *widget,
-			   GdkEvent *event,
-			   PeasExtensionSet *set)
-{
-	peas_extension_set_call (set, "deactivate");
-	return FALSE;
-}
-
 static GObject *
 eog_window_constructor (GType type,
 			guint n_construct_properties,
 			GObjectConstructParam *construct_params)
 {
 	GObject *object;
-	PeasExtensionSet *set;
+	EogWindowPrivate *priv;
 
 	object = G_OBJECT_CLASS (eog_window_parent_class)->constructor
 			(type, n_construct_properties, construct_params);
 
+	priv = EOG_WINDOW (object)->priv;
+
 	eog_window_construct_ui (EOG_WINDOW (object));
 
-	set = peas_extension_set_new (PEAS_ENGINE (EOG_APP->plugin_engine),
-				      PEAS_TYPE_ACTIVATABLE,
-				      "object", object, NULL);
-	peas_extension_set_call (set, "activate");
-	g_signal_connect (set, "extension-added",
+	priv->extensions = peas_extension_set_new (PEAS_ENGINE (EOG_APP->plugin_engine),
+						   PEAS_TYPE_ACTIVATABLE,
+						   "object", object, NULL);
+	peas_extension_set_call (priv->extensions, "activate");
+	g_signal_connect (priv->extensions, "extension-added",
 			  G_CALLBACK (on_extension_added), object);
-	g_signal_connect (set, "extension-removed",
+	g_signal_connect (priv->extensions, "extension-removed",
 			  G_CALLBACK (on_extension_removed), object);
-	g_signal_connect (object, "delete-event",
-			  G_CALLBACK (on_window_delete), set);
 
 	return object;
 }



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