Changeset 108631 in webkit


Ignore:
Timestamp:
Feb 23, 2012 8:38:02 AM (12 years ago)
Author:
sergio@webkit.org
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):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r108625 r108631  
     12012-02-23  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [WK2][GTK] WebProcess SIGSEVs due to incorrect clipboard handling
     4        https://bugs.webkit.org/show_bug.cgi?id=79252
     5
     6        Do not execute clipboard callbacks after the Frame associated with
     7        it is destroyed.
     8
     9        This change is already covered by the TestWebViewEditor unit tests
     10        (among others), they hang (because WebProcess dies) without this
     11        patch in Debug builds.
     12
     13        * WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
     14        (EditorClientFrameDestructionObserver):
     15        (WebKit::EditorClientFrameDestructionObserver::EditorClientFrameDestructionObserver):
     16        (WebKit::EditorClientFrameDestructionObserver::frameDestroyed):
     17        (WebKit::EditorClientFrameDestructionObserver::destroyOnClosureFinalization):
     18        (WebKit):
     19        (WebKit::WebEditorClient::setSelectionPrimaryClipboardIfNeeded):
     20
    1212012-02-23  Kenneth Rohde Christiansen  <kenneth@webkit.org>
    222
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp

    r106000 r108631  
    2222
    2323#include "Frame.h"
     24#include "FrameDestructionObserver.h"
    2425#include "PlatformKeyboardEvent.h"
    2526#include "WebPage.h"
     
    131132
    132133#if PLATFORM(X11)
     134class EditorClientFrameDestructionObserver : FrameDestructionObserver {
     135public:
     136    EditorClientFrameDestructionObserver(Frame* frame, GClosure* closure)
     137        : FrameDestructionObserver(frame)
     138        , m_closure(closure)
     139    {
     140        g_closure_add_finalize_notifier(m_closure, this, destroyOnClosureFinalization);
     141    }
     142
     143    void frameDestroyed()
     144    {
     145        g_closure_invalidate(m_closure);
     146        FrameDestructionObserver::frameDestroyed();
     147    }
     148private:
     149    GClosure* m_closure;
     150
     151    static void destroyOnClosureFinalization(gpointer data, GClosure* closure) { delete data; }
     152};
     153
    133154static Frame* frameSettingClipboard;
     155
    134156static void collapseSelection(GtkClipboard* clipboard, Frame* frame)
    135157{
     
    157179    frameSettingClipboard = frame;
    158180    GClosure* callback = g_cclosure_new(G_CALLBACK(collapseSelection), frame, 0);
     181    // This observer will be self-destroyed on closure finalization,
     182    // that will happen either after closure execution or after
     183    // closure invalidation.
     184    new EditorClientFrameDestructionObserver(frame, callback);
    159185    g_closure_set_marshal(callback, g_cclosure_marshal_VOID__VOID);
    160186    PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(clipboard, PasteboardHelper::DoNotIncludeSmartPaste, callback);
Note: See TracChangeset for help on using the changeset viewer.