[GTK] Remove the weak pointer added to the web view in WebKitPrintOperation
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Jan 2014 07:19:56 +0000 (07:19 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Jan 2014 07:19:56 +0000 (07:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127098

Reviewed by Martin Robinson.

If the print operation finishes and the web view is still alive,
the weak pointer added to the view should be removed.

* UIProcess/API/gtk/WebKitPrintOperation.cpp:
(_WebKitPrintOperationPrivate::~_WebKitPrintOperationPrivate):

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp

index 0d2c219..d535f4b 100644 (file)
@@ -1,3 +1,16 @@
+2014-01-16  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Remove the weak pointer added to the web view in WebKitPrintOperation
+        https://bugs.webkit.org/show_bug.cgi?id=127098
+
+        Reviewed by Martin Robinson.
+
+        If the print operation finishes and the web view is still alive,
+        the weak pointer added to the view should be removed.
+
+        * UIProcess/API/gtk/WebKitPrintOperation.cpp:
+        (_WebKitPrintOperationPrivate::~_WebKitPrintOperationPrivate):
+
 2014-01-15  Sam Weinig  <sam@webkit.org>
 
         TextBreakIterator's should support Latin-1 for all iterator types (Part 3)
index 5318dd0..35513c2 100644 (file)
@@ -65,6 +65,12 @@ enum {
 };
 
 struct _WebKitPrintOperationPrivate {
+    ~_WebKitPrintOperationPrivate()
+    {
+        if (webView)
+            g_object_remove_weak_pointer(G_OBJECT(webView), reinterpret_cast<void**>(&webView));
+    }
+
     WebKitWebView* webView;
     PrintInfo::PrintMode printMode;
 
@@ -78,13 +84,10 @@ WEBKIT_DEFINE_TYPE(WebKitPrintOperation, webkit_print_operation, G_TYPE_OBJECT)
 
 static void webkitPrintOperationConstructed(GObject* object)
 {
-    WebKitPrintOperation* printOperation = WEBKIT_PRINT_OPERATION(object);
-    WebKitPrintOperationPrivate* priv = printOperation->priv;
-
-    if (G_OBJECT_CLASS(webkit_print_operation_parent_class)->constructed)
-        G_OBJECT_CLASS(webkit_print_operation_parent_class)->constructed(object);
+    G_OBJECT_CLASS(webkit_print_operation_parent_class)->constructed(object);
 
-    g_object_add_weak_pointer(G_OBJECT(priv->webView), (gpointer*)&priv->webView);
+    WebKitPrintOperationPrivate* priv = WEBKIT_PRINT_OPERATION(object)->priv;
+    g_object_add_weak_pointer(G_OBJECT(priv->webView), reinterpret_cast<void**>(&priv->webView));
 }
 
 static void webkitPrintOperationGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec)