RESOLVED FIXED 24493
[GTK] Misc patches for WebKitWebHistoryItem
https://bugs.webkit.org/show_bug.cgi?id=24493
Summary [GTK] Misc patches for WebKitWebHistoryItem
Xan Lopez
Reported 2009-03-10 10:08:04 PDT
Ditto.
Attachments
style.patch (6.42 KB, patch)
2009-03-10 10:26 PDT, Xan Lopez
ap: review+
hashtablefull.patch (3.03 KB, patch)
2009-03-10 10:26 PDT, Xan Lopez
ap: review+
dispose.patch (2.73 KB, patch)
2009-03-10 10:27 PDT, Xan Lopez
xan.lopez: review-
fixstyle.patch (1.88 KB, patch)
2009-03-10 23:41 PDT, Xan Lopez
zecke: review+
deref.patch (2.38 KB, patch)
2009-03-10 23:42 PDT, Xan Lopez
zecke: review+
disposeonce.patch (3.00 KB, patch)
2009-03-11 02:30 PDT, Xan Lopez
zecke: review+
add WebKitWebHistoryItem unit test (5.71 KB, patch)
2009-03-11 04:22 PDT, Jan Alonzo
zecke: review+
Xan Lopez
Comment 1 2009-03-10 10:26:16 PDT
Created attachment 28439 [details] style.patch Fix coding style.
Xan Lopez
Comment 2 2009-03-10 10:26:50 PDT
Created attachment 28440 [details] hashtablefull.patch Use g_hash_table_new_full so we can save the manual unref on the values when removing them from the table.
Xan Lopez
Comment 3 2009-03-10 10:27:16 PDT
Created attachment 28441 [details] dispose.patch dispose can run more than once, so make sure we don't try to access the items hash table after it's potentially destroyed.
Alexey Proskuryakov
Comment 4 2009-03-10 10:28:58 PDT
Comment on attachment 28439 [details] style.patch r=me
Xan Lopez
Comment 5 2009-03-10 10:34:52 PDT
(In reply to comment #4) > (From update of attachment 28439 [details] [review]) > r=me > Landed in r41558, thanks.
Alexey Proskuryakov
Comment 6 2009-03-10 10:35:44 PDT
Comment on attachment 28440 [details] hashtablefull.patch r=me. It's a bit counter-intuitive that the table derefs the elements, but does not ref them automatically. Perhaps a comment would help.
Xan Lopez
Comment 7 2009-03-10 10:59:54 PDT
(In reply to comment #6) > (From update of attachment 28440 [details] [review]) > r=me. It's a bit counter-intuitive that the table derefs the elements, but does > not ref them automatically. Perhaps a comment would help. > Mmm, well, the table can't magically know what function to use to do the opposite operation of the destroy function you pass, and besides you might now want to do it in all cases...
Xan Lopez
Comment 8 2009-03-10 11:00:41 PDT
(In reply to comment #7) > (In reply to comment #6) > > (From update of attachment 28440 [details] [review] [review]) > > r=me. It's a bit counter-intuitive that the table derefs the elements, but does > > not ref them automatically. Perhaps a comment would help. > > > > Mmm, well, the table can't magically know what function to use to do the > opposite operation of the destroy function you pass, and besides you might now > want to do it in all cases... > s/now/not/ ...
Xan Lopez
Comment 9 2009-03-10 23:41:29 PDT
Created attachment 28466 [details] fixstyle.patch return foo? foo : NULL == return foo
Xan Lopez
Comment 10 2009-03-10 23:42:51 PDT
Created attachment 28467 [details] deref.patch Call deref() on our internal HistoryItem on dispose, as we always acquire it with a releaseRef() call to a PassRefPtr, which passes ownership.
Holger Freyther
Comment 11 2009-03-11 02:19:48 PDT
Comment on attachment 28441 [details] dispose.patch > static void webkit_web_history_item_dispose(GObject* object) > { > WebKitWebHistoryItem* webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(object); > - > - GHashTable* table = webkit_history_items(); > - > - g_hash_table_remove(table, core(webHistoryItem)); > - > - /* destroy table if empty */ > - if (!g_hash_table_size(table)) > - g_hash_table_destroy(table); > + static gboolean isDisposed = false; this looks wrong. For every HistoryItem we will only dispose/clear the first time one instance of HistoryItem should get destroyed? What am I missing?
Xan Lopez
Comment 12 2009-03-11 02:23:00 PDT
(In reply to comment #11) > (From update of attachment 28441 [details] [review]) > > > static void webkit_web_history_item_dispose(GObject* object) > > { > > WebKitWebHistoryItem* webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(object); > > - > > - GHashTable* table = webkit_history_items(); > > - > > - g_hash_table_remove(table, core(webHistoryItem)); > > - > > - /* destroy table if empty */ > > - if (!g_hash_table_size(table)) > > - g_hash_table_destroy(table); > > + static gboolean isDisposed = false; > > this looks wrong. For every HistoryItem we will only dispose/clear the first > time one instance of HistoryItem should get destroyed? What am I missing? > Mmm, the point is to only remove ourselves from the global hash table, and destroy it if it's empty, once, as dispose can run several times for the same GObject.
Xan Lopez
Comment 13 2009-03-11 02:24:34 PDT
Uhh, ok, nevermind. We need a per instance flag in the private data :)
Xan Lopez
Comment 14 2009-03-11 02:30:26 PDT
Created attachment 28468 [details] disposeonce.patch Something like this.
Jan Alonzo
Comment 15 2009-03-11 04:18:09 PDT
*** Bug 19898 has been marked as a duplicate of this bug. ***
Jan Alonzo
Comment 16 2009-03-11 04:22:47 PDT
Created attachment 28473 [details] add WebKitWebHistoryItem unit test adding unit test to this bug
Holger Freyther
Comment 17 2009-03-11 06:40:59 PDT
Comment on attachment 28473 [details] add WebKitWebHistoryItem unit test Looks good. the only complain/question is to multiple programs vs. one program with multiple test suites
Holger Freyther
Comment 18 2009-03-11 07:26:47 PDT
Comment on attachment 28467 [details] deref.patch okay, sounds good..
Jan Alonzo
Comment 19 2009-03-11 12:27:11 PDT
(In reply to comment #17) > (From update of attachment 28473 [details] [review]) > Looks good. the only complain/question is to multiple programs vs. one program > with multiple test suites > zecke, I think we should just split it. There's a bug about that at https://bugs.webkit.org/show_bug.cgi?id=24039 Thanks
Holger Freyther
Comment 20 2009-03-17 10:39:04 PDT
Comment on attachment 28473 [details] add WebKitWebHistoryItem unit test > # Build unit test > -noinst_PROGRAMS += Programs/UnitTests > +noinst_PROGRAMS += Programs/UnitTests Programs/WebHistoryItemUnitTests okay, this needs rediffing as of bug #24039. > +static void > +test_webkit_web_history_item_alternate_title(WebHistoryItemFixture* fixture, > + gconstpointer data) inconsistency with the new lines...
Jan Alonzo
Comment 21 2009-03-20 13:26:42 PDT
(In reply to comment #17) > (From update of attachment 28473 [details] [review]) > Looks good. the only complain/question is to multiple programs vs. one program > with multiple test suites > Landed in r41866. Closing as all other patches have been committed.
Note You need to log in before you can comment on or make changes to this bug.