[Webkit-unassigned] [Bug 108960] [GTK] Remove subresource leaks from WebKit1 and WebKit2

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Feb 15 11:14:00 PST 2013


https://bugs.webkit.org/show_bug.cgi?id=108960





--- Comment #29 from Martin Robinson <mrobinson at webkit.org>  2013-02-15 11:16:18 PST ---
(From update of attachment 188598)
View in context: https://bugs.webkit.org/attachment.cgi?id=188598&action=review

Nice. Work. I think this just a few small adjustments.

> Source/WebKit/gtk/webkit/webkitwebview.cpp:5113
> +    GList* subResources = reinterpret_cast<GList*>(data);

You actually only need a static_cast here.

> Source/WebKit/gtk/webkit/webkitwebview.cpp:5115
> +    g_list_free(subResources);

We have to be a bit careful here. The annotation for webkit_web_data_source_get_subresources: is "transfer container." That means that the application owns the container and not the contents. It seems that you'll need to put the resources into a container that you own to free them. I suggest something like this:

Vector<GRefPtr<WebKitWebResource> > gCachedResources;
static gboolean cleanupTemporarilyCachedSubresources()
{
    gCachedResources.clear();
}

And then in get_subresources the code would look like this:

for (unsigned int i = 0; i < coreSubResources.size(); i++) {
    WebKitWebResource* webResource = WEBKIT_WEB_RESOURCE(g_object_new(WEBKIT_TYPE_WEB_RESOURCE, NULL));
    webkit_web_resource_init_with_core_resource(webResource, coreSubResources[i]);
    subResources = g_list_append(subResources, webResource);
    gCachedResources.append(adoptGRef(webResorce));
}

Note that I'm using adoptGRef to avoid a reference leak and also that cleanupTemporarilyCachedSubresources follows Webkit naming conventions.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list