Commit e262c982 authored by jmalonzo@webkit.org's avatar jmalonzo@webkit.org

2009-06-20 Jan Michael Alonzo <jmalonzo@webkit.org>

        Reviewed by Gustavo Noronha and Xan Lopez.

        webkit_web_back_forward_list_add_item() should add a ref for the history item
        https://bugs.webkit.org/show_bug.cgi?id=26517

        Add a ref to the WebHistoryItem when it's added to the back
        forward list through webkit_web_back_forward_list_add_item.
        This keeps the history item alive and prevents pywebkitgtk from
        crashing

        * tests/testwebbackforwardlist.c:
        (test_webkit_web_history_item_lifetime):
        (test_webkit_web_back_forward_list_order):
        (test_webkit_web_back_forward_list_add_item):
        * webkit/webkitwebbackforwardlist.cpp:
        (webkit_web_back_forward_list_add_item):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@44903 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent bc157d8b
2009-06-20 Jan Michael Alonzo <jmalonzo@webkit.org>
Reviewed by Gustavo Noronha and Xan Lopez.
webkit_web_back_forward_list_add_item() should add a ref for the history item
https://bugs.webkit.org/show_bug.cgi?id=26517
Add a ref to the WebHistoryItem when it's added to the back
forward list through webkit_web_back_forward_list_add_item.
This keeps the history item alive and prevents pywebkitgtk from
crashing
* tests/testwebbackforwardlist.c:
(test_webkit_web_history_item_lifetime):
(test_webkit_web_back_forward_list_order):
(test_webkit_web_back_forward_list_add_item):
* webkit/webkitwebbackforwardlist.cpp:
(webkit_web_back_forward_list_add_item):
2009-06-20 Gustavo Noronha Silva <gns@gnome.org>
Reviewed by Jan Alonzo.
......
......@@ -47,15 +47,19 @@ static void test_webkit_web_history_item_lifetime(void)
/* add test items */
item1 = webkit_web_history_item_new_with_data("http://example.com/1/", "Site 1");
webkit_web_back_forward_list_add_item(backForwardList, item1);
g_object_unref(item1);
item2 = webkit_web_history_item_new_with_data("http://example.com/2/", "Site 2");
webkit_web_back_forward_list_add_item(backForwardList, item2);
g_object_unref(item2);
item3 = webkit_web_history_item_new_with_data("http://example.com/3/", "Site 3");
webkit_web_back_forward_list_add_item(backForwardList, item3);
g_object_unref(item3);
item4 = webkit_web_history_item_new_with_data("http://example.com/4/", "Site 4");
webkit_web_back_forward_list_add_item(backForwardList, item4);
g_object_unref(item4);
/* make sure these functions don't add unnecessary ref to the history item */
backItem = webkit_web_back_forward_list_get_back_item(backForwardList);
......@@ -131,18 +135,22 @@ static void test_webkit_web_back_forward_list_order(void)
// Add a new items
item1 = webkit_web_history_item_new_with_data("http://example.com/1/", "Site 1");
webkit_web_back_forward_list_add_item(webBackForwardList, item1);
g_object_unref(item1);
g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, item1));
item2 = webkit_web_history_item_new_with_data("http://example.com/2/", "Site 2");
webkit_web_back_forward_list_add_item(webBackForwardList, item2);
g_object_unref(item2);
g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, item2));
item3 = webkit_web_history_item_new_with_data("http://example.com/3/", "Site 3");
webkit_web_back_forward_list_add_item(webBackForwardList, item3);
g_object_unref(item3);
g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, item3));
item4 = webkit_web_history_item_new_with_data("http://example.com/4/", "Site 4");
webkit_web_back_forward_list_add_item(webBackForwardList, item4);
g_object_unref(item4);
g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, item4));
// check the back list order
......@@ -214,6 +222,7 @@ static void test_webkit_web_back_forward_list_add_item(void)
// Add a new item
addItem1 = webkit_web_history_item_new_with_data("http://example.com/", "Added site");
webkit_web_back_forward_list_add_item(webBackForwardList, addItem1);
g_object_unref(addItem1);
g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, addItem1));
// Check that the added item is the current item.
......@@ -229,6 +238,7 @@ static void test_webkit_web_back_forward_list_add_item(void)
// Add another item.
addItem2 = webkit_web_history_item_new_with_data("http://example.com/2/", "Added site 2");
webkit_web_back_forward_list_add_item(webBackForwardList, addItem2);
g_object_unref(addItem2);
g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, addItem2));
// Check that the added item is new current item.
......
......@@ -419,9 +419,8 @@ void webkit_web_back_forward_list_set_limit(WebKitWebBackForwardList* webBackFor
*
* Adds the item to the #WebKitWebBackForwardList.
*
* The @webBackForwardList will steal the reference of the
* @webHistoryItem, so you don't need to unref it after adding it to
* the list.
* The @webBackForwardList will add a reference to the @webHistoryItem, so you
* don't need to keep a reference once you've added it to the list.
*
* Since: 1.1.1
*/
......@@ -429,6 +428,8 @@ void webkit_web_back_forward_list_add_item(WebKitWebBackForwardList *webBackForw
{
g_return_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList));
g_object_ref(webHistoryItem);
WebCore::BackForwardList* backForwardList = core(webBackForwardList);
WebCore::HistoryItem* historyItem = core(webHistoryItem);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment