aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXan Lopez <xan@gnome.org>2009-10-23 07:51:17 +0800
committerXan Lopez <xan@gnome.org>2009-10-24 02:56:24 +0800
commit46845bbcf412994f0bb3e949178c6f72f676f70b (patch)
tree998ead5ff6fd8a86269e45313a2baa3d2afd182b /src
parentdc14e5bcab1759813aeed64af213ba067535e7e8 (diff)
downloadgsoc2013-epiphany-46845bbcf412994f0bb3e949178c6f72f676f70b.tar
gsoc2013-epiphany-46845bbcf412994f0bb3e949178c6f72f676f70b.tar.gz
gsoc2013-epiphany-46845bbcf412994f0bb3e949178c6f72f676f70b.tar.bz2
gsoc2013-epiphany-46845bbcf412994f0bb3e949178c6f72f676f70b.tar.lz
gsoc2013-epiphany-46845bbcf412994f0bb3e949178c6f72f676f70b.tar.xz
gsoc2013-epiphany-46845bbcf412994f0bb3e949178c6f72f676f70b.tar.zst
gsoc2013-epiphany-46845bbcf412994f0bb3e949178c6f72f676f70b.zip
Refactor EphyShell lifetime tracking
Stop having each EphyWindow ref the shell, and instead have the shell track all the newly created EphyWindows. When the last one is gone, quit the GTK+ mainloop. This is simpler and avoids potential reference cycles (see bug #573551). Bug #599348
Diffstat (limited to 'src')
-rw-r--r--src/ephy-main.c23
-rw-r--r--src/ephy-window.c12
2 files changed, 10 insertions, 25 deletions
diff --git a/src/ephy-main.c b/src/ephy-main.c
index 5daca6fc6..493eb91dc 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -238,16 +238,6 @@ handle_email (GtkAboutDialog *about,
}
static void
-shell_weak_notify (gpointer data,
- GObject *zombie)
-{
- if (gtk_main_level ())
- {
- gtk_main_quit ();
- }
-}
-
-static void
unref_proxy_reply_cb (DBusGProxy *proxy,
GError *error,
gpointer user_data)
@@ -468,6 +458,12 @@ save_accels (void)
g_free (filename);
}
+static void
+shell_quit_cb (EphyShell *shell, gpointer data)
+{
+ gtk_main_quit ();
+}
+
int
main (int argc,
char *argv[])
@@ -767,13 +763,10 @@ main (int argc,
/* Now create the shell */
_ephy_shell_create_instance ();
+ g_signal_connect (ephy_shell, "quit", G_CALLBACK (shell_quit_cb), NULL);
queue_commands (user_time);
- /* We'll release the initial reference on idle */
- g_object_weak_ref (G_OBJECT (ephy_shell), shell_weak_notify, NULL);
- ephy_object_idle_unref (ephy_shell);
-
#ifdef HAVE_LIBNOTIFY
/* Init notifications for the download manager */
notify_init (PACKAGE);
@@ -782,6 +775,8 @@ main (int argc,
gtk_main ();
/* Shutdown */
+ g_object_unref (ephy_shell);
+
#ifdef HAVE_LIBNOTIFY
if (notify_is_initted ())
notify_uninit ();
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 3f53fa39d..df0c7dfb1 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -458,7 +458,6 @@ struct _EphyWindowPrivate
guint is_popup : 1;
guint present_on_insert : 1;
guint key_theme_is_emacs : 1;
- guint shell_unref : 1;
};
enum
@@ -3315,15 +3314,6 @@ ephy_window_dispose (GObject *object)
destroy_fullscreen_popup (window);
G_OBJECT_CLASS (ephy_window_parent_class)->dispose (object);
-
- /* We need to unref the shell after chaining up to the parent
- * class, since our children widgets might need the shell to
- * be around for some cleanup operations */
- if (window->priv->shell_unref == FALSE)
- {
- g_object_unref (ephy_shell);
- window->priv->shell_unref = TRUE;
- }
}
static void
@@ -3642,7 +3632,7 @@ ephy_window_init (EphyWindow *window)
{
LOG ("EphyWindow initialising %p", window);
- g_object_ref (ephy_shell);
+ _ephy_embed_shell_track_object (EPHY_EMBED_SHELL (ephy_shell), G_OBJECT (window));
window->priv = EPHY_WINDOW_GET_PRIVATE (window);
}