[WPE][GTK] GUniqueOutPtr::release should return a raw pointer
authormcatanzaro@igalia.com <mcatanzaro@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Jul 2019 06:02:33 +0000 (06:02 +0000)
committermcatanzaro@igalia.com <mcatanzaro@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Jul 2019 06:02:33 +0000 (06:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199579

Reviewed by Carlos Garcia Campos.

Source/WebKit:

* NetworkProcess/glib/WebKitCachedResolver.cpp:
(webkitCachedResolverLookupByNameAsync):
(webkitCachedResolverLookupByNameWithFlagsAsync):
* UIProcess/API/glib/WebKitFaviconDatabase.cpp:
(processPendingIconsForPageURL):
(webkit_favicon_database_get_favicon):
* UIProcess/API/glib/WebKitUserContentFilterStore.cpp:
(webkit_user_content_filter_store_save_from_file):

Source/WTF:

GUniqueOutPtr::release should release to a raw pointer, rather than a GUniquePtr. If a
GUniquePtr is desired, it's trivial to construct one from the raw pointer, but all existing
callsites under Source/ would rather have a raw pointer. Currently they have to call
release().release() to get the raw pointer, which is annoying.

* wtf/glib/GUniquePtr.h:
(WTF::GUniqueOutPtr::release):

Tools:

* TestWebKitAPI/Tests/WTF/glib/GUniquePtr.cpp:
(TestWebKitAPI::TEST):

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

Source/WTF/ChangeLog
Source/WTF/wtf/glib/GUniquePtr.h
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/glib/WebKitCachedResolver.cpp
Source/WebKit/UIProcess/API/glib/WebKitFaviconDatabase.cpp
Source/WebKit/UIProcess/API/glib/WebKitUserContentFilterStore.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/glib/GUniquePtr.cpp

index c484fa1..0d29c2e 100644 (file)
@@ -1,3 +1,18 @@
+2019-07-09  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        [WPE][GTK] GUniqueOutPtr::release should return a raw pointer
+        https://bugs.webkit.org/show_bug.cgi?id=199579
+
+        Reviewed by Carlos Garcia Campos.
+
+        GUniqueOutPtr::release should release to a raw pointer, rather than a GUniquePtr. If a
+        GUniquePtr is desired, it's trivial to construct one from the raw pointer, but all existing
+        callsites under Source/ would rather have a raw pointer. Currently they have to call
+        release().release() to get the raw pointer, which is annoying.
+
+        * wtf/glib/GUniquePtr.h:
+        (WTF::GUniqueOutPtr::release):
+
 2019-07-09  Sam Weinig  <weinig@apple.com>
 
         Add StringBuilder member function which allows makeString() style variadic argument construction
index e1cff8d..ef36f26 100644 (file)
@@ -24,6 +24,7 @@
 #if USE(GLIB)
 
 #include <gio/gio.h>
+#include <utility>
 #include <wtf/Noncopyable.h>
 
 namespace WTF {
@@ -78,11 +79,9 @@ public:
         return m_ptr;
     }
 
-    GUniquePtr<T> release()
+    T* release()
     {
-        GUniquePtr<T> ptr(m_ptr);
-        m_ptr = nullptr;
-        return ptr;
+        return std::exchange(m_ptr, nullptr);
     }
 
     T& operator*() const
index b3d3620..3a522ec 100644 (file)
@@ -1,3 +1,19 @@
+2019-07-09  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        [WPE][GTK] GUniqueOutPtr::release should return a raw pointer
+        https://bugs.webkit.org/show_bug.cgi?id=199579
+
+        Reviewed by Carlos Garcia Campos.
+
+        * NetworkProcess/glib/WebKitCachedResolver.cpp:
+        (webkitCachedResolverLookupByNameAsync):
+        (webkitCachedResolverLookupByNameWithFlagsAsync):
+        * UIProcess/API/glib/WebKitFaviconDatabase.cpp:
+        (processPendingIconsForPageURL):
+        (webkit_favicon_database_get_favicon):
+        * UIProcess/API/glib/WebKitUserContentFilterStore.cpp:
+        (webkit_user_content_filter_store_save_from_file):
+
 2019-07-09  Tim Horton  <timothy_horton@apple.com>
 
         Fixed elements appear in the middle of full page screenshots taken when scrolled
index 3deab9e..2d17c22 100644 (file)
@@ -108,7 +108,7 @@ static void webkitCachedResolverLookupByNameAsync(GResolver* resolver, const cha
             priv->cache.update(asyncData->hostname, addressListGListToVector(addressList));
             g_task_return_pointer(task.get(), addressList, reinterpret_cast<GDestroyNotify>(g_resolver_free_addresses));
         } else
-            g_task_return_error(task.get(), error.release().release());
+            g_task_return_error(task.get(), error.release());
     }, task.leakRef());
 }
 
@@ -170,7 +170,7 @@ static void webkitCachedResolverLookupByNameWithFlagsAsync(GResolver* resolver,
             priv->cache.update(asyncData->hostname, addressListGListToVector(addressList), asyncData->dnsCacheType);
             g_task_return_pointer(task.get(), addressList, reinterpret_cast<GDestroyNotify>(g_resolver_free_addresses));
         } else
-            g_task_return_error(task.get(), error.release().release());
+            g_task_return_error(task.get(), error.release());
     }, task.leakRef());
 }
 
index e016486..218083e 100644 (file)
@@ -175,7 +175,7 @@ static void processPendingIconsForPageURL(WebKitFaviconDatabase* database, const
     for (size_t i = 0; i < pendingIconRequests->size(); ++i) {
         GTask* task = pendingIconRequests->at(i).get();
         if (error)
-            g_task_return_error(task, error.release().release());
+            g_task_return_error(task, error.release());
         else {
             GetFaviconSurfaceAsyncData* data = static_cast<GetFaviconSurfaceAsyncData*>(g_task_get_task_data(task));
             data->icon = icon;
@@ -413,7 +413,7 @@ void webkit_favicon_database_get_favicon(WebKitFaviconDatabase* database, const
     data->shouldReleaseIconForPageURL = true;
 
     if (g_error_matches(error.get(), WEBKIT_FAVICON_DATABASE_ERROR, WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_NOT_FOUND)) {
-        g_task_return_error(task.get(), error.release().release());
+        g_task_return_error(task.get(), error.release());
         return;
     }
 
index 6241bb5..42bd997 100644 (file)
@@ -307,7 +307,7 @@ void webkit_user_content_filter_store_save_from_file(WebKitUserContentFilterStor
             SaveTaskData* data = static_cast<SaveTaskData*>(g_task_get_task_data(task.get()));
             webkitUserContentFilterStoreSaveBytes(WTFMove(task), WTFMove(data->identifier), GRefPtr<GBytes>(g_bytes_new_take(sourceData, sourceSize)));
         } else
-            g_task_return_error(task.get(), error.release().release());
+            g_task_return_error(task.get(), error.release());
     }, task.leakRef());
 }
 
index 2642115..db0c35d 100644 (file)
@@ -1,3 +1,13 @@
+2019-07-09  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        [WPE][GTK] GUniqueOutPtr::release should return a raw pointer
+        https://bugs.webkit.org/show_bug.cgi?id=199579
+
+        Reviewed by Carlos Garcia Campos.
+
+        * TestWebKitAPI/Tests/WTF/glib/GUniquePtr.cpp:
+        (TestWebKitAPI::TEST):
+
 2019-07-09  Chris Dumez  <cdumez@apple.com>
 
         Fix integer type encoding / decoding in WKRemoteObjectCoder
index 11f02c7..288591c 100644 (file)
@@ -184,7 +184,7 @@ TEST(WTF_GUniquePtr, OutPtr)
     {
         GUniqueOutPtr<char> a;
         returnOutChar(&a.outPtr());
-        GUniquePtr<char> b = a.release();
+        GUniquePtr<char> b(a.release());
         ASSERT_STREQ(actual.str().c_str(), takeLogStr().c_str());
         actual << "g_free(" << b.get() << ");";
     }