Title: [108631] trunk/Source/WebKit2
Revision
108631
Author
ser...@webkit.org
Date
2012-02-23 08:38:02 -0800 (Thu, 23 Feb 2012)

Log Message

[WK2][GTK] WebProcess SIGSEVs due to incorrect clipboard handling
https://bugs.webkit.org/show_bug.cgi?id=79252

Do not execute clipboard callbacks after the Frame associated with
it is destroyed.

This change is already covered by the TestWebViewEditor unit tests
(among others), they hang (because WebProcess dies) without this
patch in Debug builds.

* WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
(EditorClientFrameDestructionObserver):
(WebKit::EditorClientFrameDestructionObserver::EditorClientFrameDestructionObserver):
(WebKit::EditorClientFrameDestructionObserver::frameDestroyed):
(WebKit::EditorClientFrameDestructionObserver::destroyOnClosureFinalization):
(WebKit):
(WebKit::WebEditorClient::setSelectionPrimaryClipboardIfNeeded):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (108630 => 108631)


--- trunk/Source/WebKit2/ChangeLog	2012-02-23 16:19:21 UTC (rev 108630)
+++ trunk/Source/WebKit2/ChangeLog	2012-02-23 16:38:02 UTC (rev 108631)
@@ -1,3 +1,23 @@
+2012-02-23  Sergio Villar Senin  <svil...@igalia.com>
+
+        [WK2][GTK] WebProcess SIGSEVs due to incorrect clipboard handling
+        https://bugs.webkit.org/show_bug.cgi?id=79252
+
+        Do not execute clipboard callbacks after the Frame associated with
+        it is destroyed.
+
+        This change is already covered by the TestWebViewEditor unit tests
+        (among others), they hang (because WebProcess dies) without this
+        patch in Debug builds.
+
+        * WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
+        (EditorClientFrameDestructionObserver):
+        (WebKit::EditorClientFrameDestructionObserver::EditorClientFrameDestructionObserver):
+        (WebKit::EditorClientFrameDestructionObserver::frameDestroyed):
+        (WebKit::EditorClientFrameDestructionObserver::destroyOnClosureFinalization):
+        (WebKit):
+        (WebKit::WebEditorClient::setSelectionPrimaryClipboardIfNeeded):
+
 2012-02-23  Kenneth Rohde Christiansen  <kenn...@webkit.org>
 
         [Qt] Page doesn't get repainted while panning is in progress

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp (108630 => 108631)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp	2012-02-23 16:19:21 UTC (rev 108630)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp	2012-02-23 16:38:02 UTC (rev 108631)
@@ -21,6 +21,7 @@
 #include "WebEditorClient.h"
 
 #include "Frame.h"
+#include "FrameDestructionObserver.h"
 #include "PlatformKeyboardEvent.h"
 #include "WebPage.h"
 #include "WebPageProxyMessages.h"
@@ -130,7 +131,28 @@
 }
 
 #if PLATFORM(X11)
+class EditorClientFrameDestructionObserver : FrameDestructionObserver {
+public:
+    EditorClientFrameDestructionObserver(Frame* frame, GClosure* closure)
+        : FrameDestructionObserver(frame)
+        , m_closure(closure)
+    {
+        g_closure_add_finalize_notifier(m_closure, this, destroyOnClosureFinalization);
+    }
+
+    void frameDestroyed()
+    {
+        g_closure_invalidate(m_closure);
+        FrameDestructionObserver::frameDestroyed();
+    }
+private:
+    GClosure* m_closure;
+
+    static void destroyOnClosureFinalization(gpointer data, GClosure* closure) { delete data; }
+};
+
 static Frame* frameSettingClipboard;
+
 static void collapseSelection(GtkClipboard* clipboard, Frame* frame)
 {
     if (frameSettingClipboard && frameSettingClipboard == frame)
@@ -156,6 +178,10 @@
 
     frameSettingClipboard = frame;
     GClosure* callback = g_cclosure_new(G_CALLBACK(collapseSelection), frame, 0);
+    // This observer will be self-destroyed on closure finalization,
+    // that will happen either after closure execution or after
+    // closure invalidation.
+    new EditorClientFrameDestructionObserver(frame, callback);
     g_closure_set_marshal(callback, g_cclosure_marshal_VOID__VOID);
     PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(clipboard, PasteboardHelper::DoNotIncludeSmartPaste, callback);
     frameSettingClipboard = 0;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to