Bug 26517

Summary: webkit_web_back_forward_list_add_item() should add a ref for the history item
Product: WebKit Reporter: Oliver Gerlich <oliver.gerlich>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Severity: Normal CC: jmalonzo
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Linux   
Description Flags
ref the newly created items so the caller can take ownership of the item
updated patch xan.lopez: review+

Description Oliver Gerlich 2009-06-18 14:35:15 PDT
When using the pywebkitgtk bindings to manually add a WebKitWebHistoryItem to a back-forward-list using WebKitWebBackForwardList.add_item(), the caller currently has to keep a reference to the item because otherwise the item is destroyed. Example:

for uri in ["http://example.com/1/", "http://example.com/2/"]:
    item = WebHistoryItem(uri, "")
backList = bf_list.get_back_list_with_limit(10)

This leads to a crash in the last line. Keeping the created WebHistoryItems referenced in Python (eg. by putting them into a global list) works around the problem. From what I understand, to fix this, add_item should add a reference to the item itself, so that the caller doesn't have to manually keep a reference.

This happens with webkit-gtk 1.1.9 and pywebkitgtk 1.1.5 and Python 2.6.2, on Ubuntu Jaunty (9.04).
Comment 1 Jan Alonzo 2009-06-19 17:54:07 PDT
Created attachment 31581 [details]
ref the newly created items so the caller can take ownership of the item
Comment 2 Jan Alonzo 2009-06-20 07:24:58 PDT
Created attachment 31596 [details]
updated patch

Add a ref when adding the item in the back forward list per kov and xan's feedback in IRC.
Comment 3 Xan Lopez 2009-06-20 07:37:08 PDT
Comment on attachment 31596 [details]
updated patch

Please update the docs also, r=me.
Comment 4 Jan Alonzo 2009-06-20 14:58:55 PDT
(In reply to comment #3)
> (From update of attachment 31596 [details] [review])
> Please update the docs also, r=me.

Landed in r44903