GtkTextTag ref_count problem


If Havoc reads this; I'm still finding problems with some GTK+ references not being unreferenced. This time its GtkTextTag.

Brief background for others:

I have written some C++ classes that wrap GTK+-2.0 objects. These C++ wrappers don't increase or decrease a GTK+ object's reference count; that's left up to the user. However, a dynamic C++ wrapper's destruction does depends on the wrapped GTK+ object being unreferenced, so that when the reference count reaches zero a destroy-notifier function is called which deletes the C++ wrapper. I put some code in place to track operator new and operator delete calls to help identify possible memory leaks. It just prints out at the name of all undeleted objects.

GtkTextTag problem:

I have noticed that GtkTextTag's C++ wrapper never gets deleted and have tried to trace the problem. When a GtkTextBuffer is finalized it unreferences its GtkTextTagTable. When the GtkTextTagTable is finalized it calls the following line of code:

gtk_text_tag_table_foreach (table, foreach_unref, NULL);

which unreferences each tag in the table. At the start of this function a tag has a reference count of 2 and after being unreferenced it still has a reference count of 1. When you apply a tag the 'gtk_text_buffer_real_apply_tag()' function gets called. This calls '_gtk_text_btree_tag()" which inturn calls 'gtk_text_btree_get_tag_info()' which increases the reference count of a tag. Searching through the source code I couldn't find any where that the tag gets unreferenced again, except for 'foreach_unref()' in GtkTextTagTable. When I removed the line that increases the reference count I found that GtkTextBuffer, GtkTextTagTable and GtkTextTag still worked properly and the C++ wrappers were deleted.

Is this a bug or am I making a mistake somewhere?


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]