GtkTooltip destroys the custom widget when finalized
- From: "Nicolas Soubeiran" <nicolas soubeiran gmail com>
- To: gtk-app-devel-list gnome org
- Subject: GtkTooltip destroys the custom widget when finalized
- Date: Wed, 19 Nov 2008 14:20:24 +0100
Hi all,
I was trying to do a tooltip with a custom widget that display a
GtkProgessBar showing the state of a computation in gtk 2.12.10. My program
often terminates with a memory fault : it lost the reference to the
GtkProgessBar even if I ref it (with g_object_ref).
I investigated and found that when finalized a tooltip destroy its window
and so all the widgets inside. Which I think is hazardous since the tooltip
does not create the custom widget it should not assume its destruction since
the user can still want to keep it.
So I do the following patch : in order to keep my widget, before destroying
the window I remove the custom widget from the tooltip.
Here is the diff : (in function gtk_tooltip_finalize )
195,211d194
< /* FIXEME : in some case the user can want to keep its custom widget
< since we don't create it, we should not assume its destruction
< we remove it from the tooltip so, if the user does not need it
anymore,
< it will be finalize (ref_cout == 0), otherwise it will be kept
unless
< the user unref it.
< */
< if (tooltip->custom_widget)
< {
< GtkWidget *custom = tooltip->custom_widget;
< /* Note: We must reset tooltip->custom_widget first,
< * since gtk_container_remove() will recurse into
< * gtk_tooltip_set_custom()
< */
< tooltip->custom_widget = NULL;
< gtk_container_remove (GTK_CONTAINER (tooltip->box), custom);
< g_object_unref (custom);
< }
This code is actually a duplication of what gtk_tooltip_set_custom does when
setting a new custom widget.
This code works, I do not see any memory leak in my test.
Regards
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]