After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 576091 - GtkTooltip destroy the custom widget
GtkTooltip destroy the custom widget
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
2.12.x
Other All
: Normal major
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2009-03-20 15:29 UTC by Nicolas SOUBEIRAN
Modified: 2009-05-25 07:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch-up file (34.88 KB, patch)
2009-03-20 20:05 UTC, Nicolas SOUBEIRAN
needs-work Details | Review
Remove custom widget before destroy the tooltip (354 bytes, patch)
2009-05-05 06:20 UTC, Lin Ma
needs-work Details | Review
patch (1.41 KB, patch)
2009-05-11 08:53 UTC, Lin Ma
committed Details | Review

Description Nicolas SOUBEIRAN 2009-03-20 15:29:51 UTC
Please describe the problem:
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.

Steps to reproduce:
1. Create a tooltip with custom widget
2. Show the tooltip and hide it
3. Retry to show the tooltip


Actual results:
The custom widget was destroyed : the apps SegV

Expected results:
before finalize, the tooltip should remove and unref the custom widget

Does this happen every time?
yes

Other information:
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.
Comment 1 Claudio Saavedra 2009-03-20 15:48:07 UTC
Can you generate your patch with patch -up and put it as an attachment? Otherwise it is hard to follow it.
Comment 2 Nicolas SOUBEIRAN 2009-03-20 20:05:21 UTC
Created attachment 131046 [details] [review]
patch-up file

This is the patch up file that include the correction to remove the custom widget before destroying the tooltip window
I made a function to avoid code duplication in gtk_tooltip_set_custom and gtk_tooltip_finalize : void gtk_tooltip_remove_custom (GtkTooltip *tooltip) 
(see at end of file)
Comment 3 Matthias Clasen 2009-03-25 04:31:43 UTC
Makes sense to me, but we also need to clarify the documentation of gtk_tooltip_set_custom. Also, please provide a patch instead of a full source file.
Comment 4 Lin Ma 2009-05-05 06:20:17 UTC
Created attachment 133995 [details] [review]
Remove custom widget before destroy the tooltip

Could people review and commit it. My work is blocked by this bug.
Comment 5 Matthias Clasen 2009-05-10 06:26:38 UTC
Patch looks ok to me, but as I said above, please clarify the documentation of gtk_tooltip_set_custom() - it needs to mention that custom_widget may be NULL,
and that custom_widget does not get destroyed when the tooltip goes away.

Since this is a slight change of behaviour, it is probably worth a note in README.in. Please add a 'Release notes for 2.18' section for this.
Comment 6 Lin Ma 2009-05-11 08:52:43 UTC
(In reply to comment #5)
> Patch looks ok to me, but as I said above, please clarify the documentation of
> gtk_tooltip_set_custom() - it needs to mention that custom_widget may be NULL,
> and that custom_widget does not get destroyed when the tooltip goes away.
> 
> Since this is a slight change of behaviour, it is probably worth a note in
> README.in. Please add a 'Release notes for 2.18' section for this.
> 

I will update this patch. But I'm not a native speaker, so please review the doc and feel free to revise it.
Comment 7 Lin Ma 2009-05-11 08:53:22 UTC
Created attachment 134383 [details] [review]
patch
Comment 8 Lin Ma 2009-05-21 07:50:51 UTC
Guys, are there any objections? Can anyone commit it?
Comment 9 Matthias Clasen 2009-05-23 04:07:04 UTC
Looks ok to me.
Comment 10 Lin Ma 2009-05-25 02:07:03 UTC
Matthias, my understanding for 'accepted-commit_now' is to let me commit. If I'm wrong, feel free to back it out. Thanks ;)
Comment 11 Claudio Saavedra 2009-05-25 07:49:40 UTC
You need to close the bug and mark the patch as committed after pushing it. Doing it now.