[GTK] Closing inspector window crashes wk
authorberto@igalia.com <berto@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Aug 2013 07:53:06 +0000 (07:53 +0000)
committerberto@igalia.com <berto@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Aug 2013 07:53:06 +0000 (07:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=110865

Reviewed by Carlos Garcia Campos.

Source/WebKit/gtk:

Deleting priv->corePage during the destruction of a webView will
trigger the deletion of InspectorFrontendClient. However that
object is supposed to handle the webView's destroy signal first in
order to do the necessary cleanup.

The solution is to wait until webkit_web_view_dispose finishes
before deleting priv->corePage.

* webkit/webkitwebview.cpp:
(webkit_web_view_dispose):

Tools:

Disconnect all signal handlers if the inspector window is
destroyed.

* GtkLauncher/LauncherInspectorWindow.c:
(inspectorWindowDestroyed):
(launcherInspectorWindowNew):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@153991 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/webkit/webkitwebview.cpp
Tools/ChangeLog
Tools/GtkLauncher/LauncherInspectorWindow.c

index 0feffac..79f2d10 100644 (file)
@@ -1,3 +1,21 @@
+2013-08-13  Alberto Garcia  <berto@igalia.com>
+
+        [GTK] Closing inspector window crashes wk
+        https://bugs.webkit.org/show_bug.cgi?id=110865
+
+        Reviewed by Carlos Garcia Campos.
+
+        Deleting priv->corePage during the destruction of a webView will
+        trigger the deletion of InspectorFrontendClient. However that
+        object is supposed to handle the webView's destroy signal first in
+        order to do the necessary cleanup.
+
+        The solution is to wait until webkit_web_view_dispose finishes
+        before deleting priv->corePage.
+
+        * webkit/webkitwebview.cpp:
+        (webkit_web_view_dispose):
+
 2013-08-12  Anton Obzhirov  <a.obzhirov@samsung.com>
 
         [GTK] Don't load GAIL when using GTK 3.2 or greater
index 5ff7fbb..1a0ac61 100644 (file)
@@ -1340,13 +1340,6 @@ static void webkit_web_view_dispose(GObject* object)
     // very sensitive to their value. We may crash if these are done in the wrong order.
     priv->backForwardList.clear();
 
-    if (priv->corePage) {
-        webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(object));
-        core(priv->mainFrame)->loader()->detachFromParent();
-        delete priv->corePage;
-        priv->corePage = 0;
-    }
-
     if (priv->webSettings) {
         g_signal_handlers_disconnect_by_func(priv->webSettings.get(), reinterpret_cast<void*>(webkit_web_view_settings_notify), webView);
         priv->webSettings.clear();
@@ -1364,6 +1357,16 @@ static void webkit_web_view_dispose(GObject* object)
     priv->subResources.clear();
 
     G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object);
+
+    // We need to run the parent's dispose before destroying
+    // priv->corePage. Otherwise we're triggering the deletion of
+    // InspectorFrontendClient before it can clean up itself.
+    if (priv->corePage) {
+        webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(object));
+        core(priv->mainFrame)->loader()->detachFromParent();
+        delete priv->corePage;
+        priv->corePage = 0;
+    }
 }
 
 static void webkit_web_view_finalize(GObject* object)
index 73f4b7d..d779b58 100644 (file)
@@ -1,3 +1,17 @@
+2013-08-13  Alberto Garcia  <berto@igalia.com>
+
+        [GTK] Closing inspector window crashes wk
+        https://bugs.webkit.org/show_bug.cgi?id=110865
+
+        Reviewed by Carlos Garcia Campos.
+
+        Disconnect all signal handlers if the inspector window is
+        destroyed.
+
+        * GtkLauncher/LauncherInspectorWindow.c:
+        (inspectorWindowDestroyed):
+        (launcherInspectorWindowNew):
+
 2013-08-12  Dan Bernstein  <mitz@apple.com>
 
         extract-localizable-strings output is not suited for parsing by Xcode
index f07cf7e..8ee9fcf 100644 (file)
@@ -78,6 +78,11 @@ static gboolean closeInspectorWindow(WebKitWebInspector *inspector, LauncherInsp
     return TRUE;
 }
 
+static void inspectorWindowDestroyed(gpointer inspector, GObject* inspectorWindow)
+{
+    g_signal_handlers_disconnect_by_data(inspector, inspectorWindow);
+}
+
 GtkWidget *launcherInspectorWindowNew(WebKitWebInspector *inspector, GtkWindow *parent)
 {
     LauncherInspectorWindow *inspectorWindow = LAUNCHER_INSPECTOR_WINDOW(g_object_new(LAUNCHER_TYPE_INSPECTOR_WINDOW, "type", GTK_WINDOW_TOPLEVEL, NULL));
@@ -97,6 +102,8 @@ GtkWidget *launcherInspectorWindowNew(WebKitWebInspector *inspector, GtkWindow *
     g_signal_connect(inspector, "show-window", G_CALLBACK(showInspectorWindow), inspectorWindow);
     g_signal_connect(inspector, "close-window", G_CALLBACK(closeInspectorWindow), inspectorWindow);
 
+    g_object_weak_ref(G_OBJECT(inspectorWindow), inspectorWindowDestroyed, inspector);
+
     return GTK_WIDGET(inspectorWindow);
 }