From 55bcddfd18577f6363842ad3b1772e0db9f1c011 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Fri, 10 Jun 2005 21:21:36 +0000 Subject: Common helper function to unref a GObject from idle. 2005-06-10 Christian Persch * lib/Makefile.am: * lib/ephy-object-helpers.c: * lib/ephy-object-helpers.h: Common helper function to unref a GObject from idle. * embed/downloader-view.c: (downloader_view_finalize): * embed/mozilla/mozilla-embed-find.cpp: * embed/mozilla/mozilla-embed-persist.cpp: * embed/mozilla/mozilla-embed.cpp: * src/ephy-extensions-manager.c: (unload_extension): * src/ephy-main.c: (main): * src/ephy-shell.c: (toolwindow_hide_cb): * src/ephy-window.c: (ephy_window_finalize): Always unref the shell from idle, never directly. That's because in case we hold the last reference, we would end up terminating embedding/XPCOM from a mozilla callback. Fixes bug #151037, and moz#236688. --- src/ephy-extensions-manager.c | 11 ++--------- src/ephy-main.c | 10 ++-------- src/ephy-shell.c | 4 +++- src/ephy-window.c | 3 ++- 4 files changed, 9 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/ephy-extensions-manager.c b/src/ephy-extensions-manager.c index 055178a56..a140ad34d 100644 --- a/src/ephy-extensions-manager.c +++ b/src/ephy-extensions-manager.c @@ -31,6 +31,7 @@ #include "ephy-shell.h" #include "eel-gconf-extensions.h" #include "ephy-file-helpers.h" +#include "ephy-object-helpers.h" #include "ephy-debug.h" #include @@ -891,14 +892,6 @@ detach_window (EphyWindow *window, ephy_extension_detach_window (extension, window); } -static gboolean -idle_unref (GObject *object) -{ - g_object_unref (object); - - return FALSE; -} - static void unload_extension (EphyExtensionsManager *manager, ExtensionInfo *info) @@ -925,7 +918,7 @@ unload_extension (EphyExtensionsManager *manager, * extension has its own functions queued in the idle loop, the * functions must exist in memory before being called. */ - g_idle_add ((GSourceFunc) idle_unref, info->extension); + ephy_object_idle_unref (info->extension); } ephy_loader_release_object (info->loader, G_OBJECT (info->extension)); diff --git a/src/ephy-main.c b/src/ephy-main.c index 4305d8175..d60d15a52 100644 --- a/src/ephy-main.c +++ b/src/ephy-main.c @@ -22,6 +22,7 @@ #include "ephy-shell.h" #include "ephy-file-helpers.h" +#include "ephy-object-helpers.h" #include "ephy-state.h" #include "ephy-debug.h" #include "ephy-stock-icons.h" @@ -135,13 +136,6 @@ shell_weak_notify (gpointer data, gtk_main_quit (); } -static gboolean -idle_unref (GObject *object) -{ - g_object_unref (object); - return FALSE; -} - /* Copied from libnautilus/nautilus-program-choosing.c; Needed in case * we have no DESKTOP_STARTUP_ID (with its accompanying timestamp). */ @@ -308,7 +302,7 @@ main (int argc, char *argv[]) else if (new_instance && ephy_shell) { g_object_weak_ref (G_OBJECT (ephy_shell), shell_weak_notify, NULL); - g_idle_add ((GSourceFunc) idle_unref, ephy_shell); + ephy_object_idle_unref (ephy_shell); gtk_main (); } diff --git a/src/ephy-shell.c b/src/ephy-shell.c index ab555f905..4b9bd1993 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -47,6 +47,7 @@ #include "print-dialog.h" #include "ephy-prefs.h" #include "ephy-gui.h" +#include "ephy-object-helpers.h" #ifdef ENABLE_DBUS #include "ephy-dbus.h" @@ -940,7 +941,8 @@ toolwindow_hide_cb (GtkWidget *widget, EphyShell *es) session = EPHY_SESSION (ephy_shell_get_session (es)); ephy_session_remove_window (ephy_shell->priv->session, GTK_WINDOW (widget)); - g_object_unref (ephy_shell); + + ephy_object_idle_unref (ephy_shell); } GtkWidget * diff --git a/src/ephy-window.c b/src/ephy-window.c index 4404d90ec..1d6b22996 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -56,6 +56,7 @@ #include "ephy-fullscreen-popup.h" #include "ephy-action-helper.h" #include "ephy-find-toolbar.h" +#include "ephy-object-helpers.h" #include #include @@ -2852,7 +2853,7 @@ ephy_window_finalize (GObject *object) LOG ("Ephy Window finalized %p", object); - g_object_unref (ephy_shell); + ephy_object_idle_unref (ephy_shell); } /** -- cgit v1.2.3