From abe1a40d562514cfe6b3c8dae1397d511062ddab Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Sun, 2 Oct 2005 18:50:51 +0000 Subject: Use nsIDOMWindowInternal::Close to close tabs. Delay tabs destruction to 2005-10-02 Christian Persch * configure.ac: * embed/ephy-embed-shell.c: (ephy_embed_shell_dispose), (ephy_embed_shell_finalize), (ephy_embed_shell_class_init): * embed/ephy-embed.c: (ephy_embed_base_init), (ephy_embed_show_page_certificate), (ephy_embed_close): * embed/ephy-embed.h: * embed/mozilla/EphyBrowser.cpp: * embed/mozilla/EphyBrowser.h: * embed/mozilla/mozilla-embed.cpp: * src/ephy-notebook.c: (ephy_notebook_class_init), (close_button_clicked_cb): * src/ephy-notebook.h: * src/ephy-python.c: (ephy_python_init), (ephy_python_shutdown), (ephy_python_schedule_gc): * src/ephy-shell.c: (ephy_shell_class_init), (gnome_session_init), (ephy_shell_dispose), (ephy_shell_finalize): * src/ephy-tab.c: (ephy_tab_init): * src/ephy-window.c: (construct_confirm_close_dialog), (confirm_close_with_modified_forms), (embed_modal_alert_cb), (idle_tab_remove_cb), (schedule_tab_close), (embed_close_request_cb), (embed_destroy_browser_cb), (tab_added_cb), (tab_removed_cb), (tab_close_request_cb), (setup_notebook), (remove_true), (ephy_window_dispose), (cancel_handler), (ephy_window_init), (ephy_window_finalize): * src/window-commands.c: (event_with_shift), (window_cmd_view_reload), (window_cmd_file_close_window): Use nsIDOMWindowInternal::Close to close tabs. Delay tabs destruction to an idle handler, to avoid crashes when tabs are closed from signal handlers (blur, mousedown, keydown etc). Fixes bug #172878, bug #172879, bug #172882, bug #303254, bug #313425. --- src/ephy-shell.c | 73 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 33 deletions(-) (limited to 'src/ephy-shell.c') diff --git a/src/ephy-shell.c b/src/ephy-shell.c index 0fba9847f..ac48e82b3 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -91,6 +91,7 @@ EphyShell *ephy_shell = NULL; static void ephy_shell_class_init (EphyShellClass *klass); static void ephy_shell_init (EphyShell *shell); +static void ephy_shell_dispose (GObject *object); static void ephy_shell_finalize (GObject *object); static GObject *impl_get_embed_single (EphyEmbedShell *embed_shell); @@ -145,6 +146,7 @@ ephy_shell_class_init (EphyShellClass *klass) parent_class = g_type_class_peek_parent (klass); + object_class->dispose = ephy_shell_dispose; object_class->finalize = ephy_shell_finalize; embed_shell_class->get_embed_single = impl_get_embed_single; @@ -414,14 +416,13 @@ gnome_session_init (EphyShell *shell) client = gnome_master_client (); - g_signal_connect (G_OBJECT (client), - "save_yourself", - G_CALLBACK (save_yourself_cb), - shell); - g_signal_connect (G_OBJECT (client), - "die", - G_CALLBACK (die_cb), - shell); + g_signal_connect_object (client, "save_yourself", + G_CALLBACK (save_yourself_cb), shell, 0); + /* don't use connect_object here, since that will ref the shell + * while dispatching the callbacks! + */ + g_signal_connect (client, "die", + G_CALLBACK (die_cb), shell); } gboolean @@ -525,101 +526,107 @@ done: } static void -ephy_shell_finalize (GObject *object) +ephy_shell_dispose (GObject *object) { EphyShell *shell = EPHY_SHELL (object); - g_assert (ephy_shell == NULL); + LOG ("EphyShell disposing"); + + if (shell->priv->automation_factory) + { + LOG ("Deregistering bonobo server"); + bonobo_activation_unregister_active_server + (AUTOMATION_FACTORY_IID, BONOBO_OBJREF (shell->priv->automation_factory)); + + bonobo_object_unref (shell->priv->automation_factory); + } - /* this will unload the extensions */ - LOG ("Unref extension manager"); if (shell->priv->extensions_manager) { + LOG ("Unref extension manager"); + /* this will unload the extensions */ g_object_unref (shell->priv->extensions_manager); } #ifdef ENABLE_DBUS - LOG ("Shutting down DBUS service"); if (shell->priv->dbus_service) { + LOG ("Shutting down DBUS service"); g_object_unref (shell->priv->dbus_service); } #endif - LOG ("Unref session manager"); if (shell->priv->session) { + LOG ("Unref session manager"); g_object_unref (shell->priv->session); } - LOG ("Unref lockdown controller"); if (shell->priv->lockdown) { + LOG ("Unref lockdown controller"); g_object_unref (shell->priv->lockdown); } - LOG ("Unref toolbars model"); if (shell->priv->toolbars_model) { + LOG ("Unref toolbars model"); g_object_unref (shell->priv->toolbars_model); } - LOG ("Unref fullscreen toolbars model"); if (shell->priv->fs_toolbars_model) { + LOG ("Unref fullscreen toolbars model"); g_object_unref (shell->priv->fs_toolbars_model); } - LOG ("Unref Bookmarks Editor"); if (shell->priv->bme) { + LOG ("Unref Bookmarks Editor"); gtk_widget_destroy (GTK_WIDGET (shell->priv->bme)); } - LOG ("Unref History Window"); if (shell->priv->history_window) { + LOG ("Unref History Window"); gtk_widget_destroy (GTK_WIDGET (shell->priv->history_window)); } - LOG ("Unref PDM Dialog"); if (shell->priv->pdm_dialog) { + LOG ("Unref PDM Dialog"); g_object_unref (shell->priv->pdm_dialog); } - LOG ("Unref prefs dialog"); if (shell->priv->prefs_dialog) { + LOG ("Unref prefs dialog"); g_object_unref (shell->priv->prefs_dialog); } - LOG ("Unref print setup dialog"); if (shell->priv->print_setup_dialog) { + LOG ("Unref print setup dialog"); g_object_unref (shell->priv->print_setup_dialog); } - LOG ("Unref bookmarks"); if (shell->priv->bookmarks) { + LOG ("Unref bookmarks"); g_object_unref (shell->priv->bookmarks); } - G_OBJECT_CLASS (parent_class)->finalize (object); - - if (shell->priv->automation_factory) - { - bonobo_activation_unregister_active_server - (AUTOMATION_FACTORY_IID, BONOBO_OBJREF (shell->priv->automation_factory)); + G_OBJECT_CLASS (parent_class)->dispose (object); +} - bonobo_object_unref (shell->priv->automation_factory); - } +static void +ephy_shell_finalize (GObject *object) +{ + G_OBJECT_CLASS (parent_class)->finalize (object); - LOG ("Ephy shell finalized"); + LOG ("Ephy shell finalised"); } - /** * ephy_shell_get_default: * -- cgit