Bug 54902 - [Qt] [WK2] Improve the memory handling of the context menu for WebKit 2
Summary: [Qt] [WK2] Improve the memory handling of the context menu for WebKit 2
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Benjamin Poulain
URL:
Keywords: Qt, QtTriaged
Depends on:
Blocks:
 
Reported: 2011-02-21 12:52 PST by Benjamin Poulain
Modified: 2011-02-22 05:25 PST (History)
1 user (show)

See Also:


Attachments
Patch (8.35 KB, patch)
2011-02-21 12:59 PST, Benjamin Poulain
no flags Details | Formatted Diff | Diff
Patch (8.36 KB, patch)
2011-02-22 04:33 PST, Benjamin Poulain
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Poulain 2011-02-21 12:52:47 PST
Currently, the QWKPage emit a signal when the context menu should be shown, a pointer to the menu being passed as parameter. The memory is handled by the receiver of the signal.

I did the design that way because the WebKit 2 apis do not prevent showContextMenu() from being called multiple time.

I now think it was a mistake because that make memory handling unreliable, and couple QGraphicsWKView and QWKPage via signals, which is a terrible idea... For example, disconnecting the default signal-slot connexion leaks the menus.
Comment 1 Benjamin Poulain 2011-02-21 12:59:43 PST
Created attachment 83208 [details]
Patch
Comment 2 Kenneth Rohde Christiansen 2011-02-22 00:37:46 PST
Comment on attachment 83208 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=83208&action=review

> Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.cpp:97
> +    OwnPtr<QMenu> menu(new QMenu);

Why not create this as a PassOwnPtr? like in the PassRefPtr example here? http://www.webkit.org/coding/RefPtr.html
Comment 3 Benjamin Poulain 2011-02-22 02:34:13 PST
(In reply to comment #2)
> Why not create this as a PassOwnPtr? like in the PassRefPtr example here? http://www.webkit.org/coding/RefPtr.html

I think the semantic of OwnPtr is better than PassPtr for this function.

In the doc you mention, on top of the example, there is 
// example, not preferred style; should use RefCounted and adoptRef (see below)

 there is "we recommend PassRefPtr only for function argument and result types" in the text.
Comment 4 Benjamin Poulain 2011-02-22 02:35:27 PST
Comment on attachment 83208 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=83208&action=review

>> Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.cpp:97
>> +    OwnPtr<QMenu> menu(new QMenu);
> 
> Why not create this as a PassOwnPtr? like in the PassRefPtr example here? http://www.webkit.org/coding/RefPtr.html

This should use adoptPtr() or it won't build without LOOSE_PASS_OWN_PTR defined.
Comment 5 Benjamin Poulain 2011-02-22 04:33:16 PST
Created attachment 83299 [details]
Patch
Comment 6 WebKit Commit Bot 2011-02-22 05:25:30 PST
Comment on attachment 83299 [details]
Patch

Clearing flags on attachment: 83299

Committed r79316: <http://trac.webkit.org/changeset/79316>
Comment 7 WebKit Commit Bot 2011-02-22 05:25:35 PST
All reviewed patches have been landed.  Closing bug.