Changeset 44903 in webkit


Ignore:
Timestamp:
Jun 20, 2009 2:56:54 PM (15 years ago)
Author:
jmalonzo@webkit.org
Message:

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):
Location:
trunk/WebKit/gtk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/gtk/ChangeLog

    r44898 r44903  
     12009-06-20  Jan Michael Alonzo  <jmalonzo@webkit.org>
     2
     3        Reviewed by Gustavo Noronha and Xan Lopez.
     4
     5        webkit_web_back_forward_list_add_item() should add a ref for the history item
     6        https://bugs.webkit.org/show_bug.cgi?id=26517
     7
     8        Add a ref to the WebHistoryItem when it's added to the back
     9        forward list through webkit_web_back_forward_list_add_item.
     10        This keeps the history item alive and prevents pywebkitgtk from
     11        crashing
     12
     13        * tests/testwebbackforwardlist.c:
     14        (test_webkit_web_history_item_lifetime):
     15        (test_webkit_web_back_forward_list_order):
     16        (test_webkit_web_back_forward_list_add_item):
     17        * webkit/webkitwebbackforwardlist.cpp:
     18        (webkit_web_back_forward_list_add_item):
     19
    1202009-06-20  Gustavo Noronha Silva  <gns@gnome.org>
    221
  • trunk/WebKit/gtk/tests/testwebbackforwardlist.c

    r44228 r44903  
    4848    item1 = webkit_web_history_item_new_with_data("http://example.com/1/", "Site 1");
    4949    webkit_web_back_forward_list_add_item(backForwardList, item1);
     50    g_object_unref(item1);
    5051
    5152    item2 = webkit_web_history_item_new_with_data("http://example.com/2/", "Site 2");
    5253    webkit_web_back_forward_list_add_item(backForwardList, item2);
     54    g_object_unref(item2);
    5355
    5456    item3 = webkit_web_history_item_new_with_data("http://example.com/3/", "Site 3");
    5557    webkit_web_back_forward_list_add_item(backForwardList, item3);
     58    g_object_unref(item3);
    5659
    5760    item4 = webkit_web_history_item_new_with_data("http://example.com/4/", "Site 4");
    5861    webkit_web_back_forward_list_add_item(backForwardList, item4);
     62    g_object_unref(item4);
    5963
    6064    /* make sure these functions don't add unnecessary ref to the history item */
     
    132136    item1 = webkit_web_history_item_new_with_data("http://example.com/1/", "Site 1");
    133137    webkit_web_back_forward_list_add_item(webBackForwardList, item1);
     138    g_object_unref(item1);
    134139    g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, item1));
    135140
    136141    item2 = webkit_web_history_item_new_with_data("http://example.com/2/", "Site 2");
    137142    webkit_web_back_forward_list_add_item(webBackForwardList, item2);
     143    g_object_unref(item2);
    138144    g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, item2));
    139145
    140146    item3 = webkit_web_history_item_new_with_data("http://example.com/3/", "Site 3");
    141147    webkit_web_back_forward_list_add_item(webBackForwardList, item3);
     148    g_object_unref(item3);
    142149    g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, item3));
    143150
    144151    item4 = webkit_web_history_item_new_with_data("http://example.com/4/", "Site 4");
    145152    webkit_web_back_forward_list_add_item(webBackForwardList, item4);
     153    g_object_unref(item4);
    146154    g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, item4));
    147155
     
    215223    addItem1 = webkit_web_history_item_new_with_data("http://example.com/", "Added site");
    216224    webkit_web_back_forward_list_add_item(webBackForwardList, addItem1);
     225    g_object_unref(addItem1);
    217226    g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, addItem1));
    218227
     
    230239    addItem2 = webkit_web_history_item_new_with_data("http://example.com/2/", "Added site 2");
    231240    webkit_web_back_forward_list_add_item(webBackForwardList, addItem2);
     241    g_object_unref(addItem2);
    232242    g_assert(webkit_web_back_forward_list_contains_item(webBackForwardList, addItem2));
    233243
  • trunk/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp

    r44228 r44903  
    420420 * Adds the item to the #WebKitWebBackForwardList.
    421421 *
    422  * The @webBackForwardList will steal the reference of the
    423  * @webHistoryItem, so you don't need to unref it after adding it to
    424  * the list.
     422 * The @webBackForwardList will add a reference to the @webHistoryItem, so you
     423 * don't need to keep a reference once you've added it to the list.
    425424 *
    426425 * Since: 1.1.1
     
    430429    g_return_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList));
    431430
     431    g_object_ref(webHistoryItem);
     432
    432433    WebCore::BackForwardList* backForwardList = core(webBackForwardList);
    433434    WebCore::HistoryItem* historyItem = core(webHistoryItem);
Note: See TracChangeset for help on using the changeset viewer.