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.
Created attachment 83208 [details] Patch
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
(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 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.
Created attachment 83299 [details] Patch
Comment on attachment 83299 [details] Patch Clearing flags on attachment: 83299 Committed r79316: <http://trac.webkit.org/changeset/79316>
All reviewed patches have been landed. Closing bug.