Title: [101136] trunk/Source/WebKit2
Revision
101136
Author
[email protected]
Date
2011-11-24 05:45:16 -0800 (Thu, 24 Nov 2011)

Log Message

[Qt][WK2] Stop leaking memory in string QWK2 API's
https://bugs.webkit.org/show_bug.cgi?id=72558

Patch by Oleg Romashin <[email protected]> on 2011-11-17
Reviewed by Simon Hausmann.

WKRef API pointers don't adopt the implementation pointers by default and the implementation pointers
stay alive after destroying the API pointers.
This patch adopts the implementation pointers correctly by using adoptWK that returns a WKRetainPtr
that will be around temporarily and correctly release the object.

* UIProcess/qt/QtWebPageUIClient.cpp:
(QtWebPageUIClient::mouseDidMoveOverElement):
* UIProcess/qt/QtDownloadManager.cpp:
(WebKit::qt_wk_didFailDownload):
* UIProcess/qt/QtWebPageProxy.cpp:
(QtWebPageProxy::load):
(QtWebPageProxy::url):
(QtWebPageProxy::title):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (101135 => 101136)


--- trunk/Source/WebKit2/ChangeLog	2011-11-24 13:35:10 UTC (rev 101135)
+++ trunk/Source/WebKit2/ChangeLog	2011-11-24 13:45:16 UTC (rev 101136)
@@ -1,3 +1,24 @@
+2011-11-17  Oleg Romashin  <[email protected]>
+
+        [Qt][WK2] Stop leaking memory in string QWK2 API's
+        https://bugs.webkit.org/show_bug.cgi?id=72558
+
+        Reviewed by Simon Hausmann.
+
+        WKRef API pointers don't adopt the implementation pointers by default and the implementation pointers
+        stay alive after destroying the API pointers.
+        This patch adopts the implementation pointers correctly by using adoptWK that returns a WKRetainPtr
+        that will be around temporarily and correctly release the object.
+
+        * UIProcess/qt/QtWebPageUIClient.cpp:
+        (QtWebPageUIClient::mouseDidMoveOverElement):
+        * UIProcess/qt/QtDownloadManager.cpp:
+        (WebKit::qt_wk_didFailDownload):
+        * UIProcess/qt/QtWebPageProxy.cpp:
+        (QtWebPageProxy::load):
+        (QtWebPageProxy::url):
+        (QtWebPageProxy::title):
+
 2011-11-24  Tor Arne Vestbø  <[email protected]>
 
         [Qt] Get rid of the buildDirForSource() function in the build system

Modified: trunk/Source/WebKit2/UIProcess/qt/QtDownloadManager.cpp (101135 => 101136)


--- trunk/Source/WebKit2/UIProcess/qt/QtDownloadManager.cpp	2011-11-24 13:35:10 UTC (rev 101135)
+++ trunk/Source/WebKit2/UIProcess/qt/QtDownloadManager.cpp	2011-11-24 13:45:16 UTC (rev 101136)
@@ -55,7 +55,7 @@
 
 static void qt_wk_didFailDownload(WKContextRef context, WKDownloadRef download, WKErrorRef error, const void *clientInfo)
 {
-    QUrl failingUrl = WKURLCopyQUrl(WKErrorCopyFailingURL(error));
+    QUrl failingUrl = WKURLCopyQUrl(adoptWK(WKErrorCopyFailingURL(error)).get());
 
     toQtDownloadManager(clientInfo)->downloadFailed(toImpl(download), QtWebError(error));
 }

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp (101135 => 101136)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp	2011-11-24 13:35:10 UTC (rev 101135)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp	2011-11-24 13:45:16 UTC (rev 101136)
@@ -730,7 +730,7 @@
 
 void QtWebPageProxy::load(const QUrl& url)
 {
-    WKRetainPtr<WKURLRef> wkurl(WKURLCreateWithQUrl(url));
+    WKRetainPtr<WKURLRef> wkurl = adoptWK(WKURLCreateWithQUrl(url));
     WKPageLoadURL(pageRef(), wkurl.get());
 }
 
@@ -739,12 +739,12 @@
     WKRetainPtr<WKFrameRef> frame = WKPageGetMainFrame(pageRef());
     if (!frame)
         return QUrl();
-    return WKURLCopyQUrl(WKFrameCopyURL(frame.get()));
+    return WKURLCopyQUrl(adoptWK(WKFrameCopyURL(frame.get())).get());
 }
 
 QString QtWebPageProxy::title() const
 {
-    return WKStringCopyQString(WKPageCopyTitle(toAPI(m_webPageProxy.get())));
+    return WKStringCopyQString(adoptWK(WKPageCopyTitle(toAPI(m_webPageProxy.get()))).get());
 }
 
 void QtWebPageProxy::setDrawingAreaSize(const QSize& size)

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp (101135 => 101136)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp	2011-11-24 13:35:10 UTC (rev 101135)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp	2011-11-24 13:45:16 UTC (rev 101136)
@@ -135,7 +135,7 @@
 
 void QtWebPageUIClient::mouseDidMoveOverElement(WKPageRef page, WKHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef userData, const void* clientInfo)
 {
-    const QUrl absoluteLinkUrl = WKURLCopyQUrl(WKHitTestResultCopyAbsoluteLinkURL(hitTestResult));
-    const QString linkTitle = WKStringCopyQString(WKHitTestResultCopyLinkTitle(hitTestResult));
+    const QUrl absoluteLinkUrl = WKURLCopyQUrl(adoptWK(WKHitTestResultCopyAbsoluteLinkURL(hitTestResult)).get());
+    const QString linkTitle = WKStringCopyQString(adoptWK(WKHitTestResultCopyLinkTitle(hitTestResult)).get());
     toQtWebPageUIClient(clientInfo)->mouseDidMoveOverElement(absoluteLinkUrl, linkTitle);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to