Bug 26517 - webkit_web_back_forward_list_add_item() should add a ref for the history item
Summary: webkit_web_back_forward_list_add_item() should add a ref for the history item
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-18 14:35 PDT by Oliver Gerlich
Modified: 2009-06-20 14:58 PDT (History)
1 user (show)

See Also:


Attachments
ref the newly created items so the caller can take ownership of the item (5.38 KB, patch)
2009-06-19 17:54 PDT, Jan Alonzo
no flags Details | Formatted Diff | Diff
updated patch (4.70 KB, patch)
2009-06-20 07:24 PDT, Jan Alonzo
xan.lopez: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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, "")
    bf_list.add_item(item)
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