Changeset 162057 in webkit


Ignore:
Timestamp:
Jan 14, 2014 11:56:42 PM (10 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] UI process crashes when closing the window right after printing with javascript
https://bugs.webkit.org/show_bug.cgi?id=126981

Reviewed by Gustavo Noronha Silva.

The UI process crashes because when the page is closed, the web
view is destroyed before the print operation has actually
finished. Use a weak pointer to make sure the web view pointer is
set to NULL when the it's destroyed and emit the finished callback
always so that the user can clean up the operation even when the
web view has been closed.

  • UIProcess/API/gtk/WebKitPrintOperation.cpp:

(drawPagesForPrintingCompleted):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r162056 r162057  
     12014-01-14  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] UI process crashes when closing the window right after printing with javascript
     4        https://bugs.webkit.org/show_bug.cgi?id=126981
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        The UI process crashes because when the page is closed, the web
     9        view is destroyed before the print operation has actually
     10        finished. Use a weak pointer to make sure the web view pointer is
     11        set to NULL when the it's destroyed and emit the finished callback
     12        always so that the user can clean up the operation even when the
     13        web view has been closed.
     14
     15        * UIProcess/API/gtk/WebKitPrintOperation.cpp:
     16        (drawPagesForPrintingCompleted):
     17
    1182014-01-14  Carlos Garcia Campos  <cgarcia@igalia.com>
    219
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp

    r162056 r162057  
    6666
    6767struct _WebKitPrintOperationPrivate {
    68     ~_WebKitPrintOperationPrivate()
    69     {
    70         g_signal_handler_disconnect(webView, webViewDestroyedId);
    71     }
    72 
    7368    WebKitWebView* webView;
    74     gulong webViewDestroyedId;
    7569    PrintInfo::PrintMode printMode;
    7670
     
    8377WEBKIT_DEFINE_TYPE(WebKitPrintOperation, webkit_print_operation, G_TYPE_OBJECT)
    8478
    85 static void webViewDestroyed(GtkWidget* webView, GObject* printOperation)
    86 {
    87     g_object_unref(printOperation);
    88 }
    89 
    9079static void webkitPrintOperationConstructed(GObject* object)
    9180{
     
    9685        G_OBJECT_CLASS(webkit_print_operation_parent_class)->constructed(object);
    9786
    98     priv->webViewDestroyedId = g_signal_connect(priv->webView, "destroy", G_CALLBACK(webViewDestroyed), printOperation);
     87    g_object_add_weak_pointer(G_OBJECT(priv->webView), (gpointer*)&priv->webView);
    9988}
    10089
     
    264253{
    265254    GRefPtr<WebKitPrintOperation> printOperation = adoptGRef(WEBKIT_PRINT_OPERATION(context));
    266     WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(printOperation->priv->webView));
    267255
    268256    // When running synchronously WebPageProxy::printFrame() calls endPrinting().
    269     if (printOperation->priv->printMode == PrintInfo::PrintModeAsync)
     257    if (printOperation->priv->printMode == PrintInfo::PrintModeAsync && printOperation->priv->webView) {
     258        WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(printOperation->priv->webView));
    270259        page->endPrinting();
     260    }
    271261
    272262    const WebCore::ResourceError& resourceError = wkPrintError ? toImpl(wkPrintError)->platformError() : WebCore::ResourceError();
Note: See TracChangeset for help on using the changeset viewer.