GNOME Bugzilla – Bug 741529
child popover ownership issue with template and GtkMenuButton
Last modified: 2018-04-15 00:25:17 UTC
I've noticed that the gtk_widget_destroy() process gets confused with my XML template. In the following situation, both my widget and the GtkMenuButton will try to call gtk_widget_destroy() on the popover. 1) create a generic container widget 2) outside the <template></template> create a GtkPopover with id="popover" 3) Assign the "popover" property of a GtkMenuButton in the template to "popover" During the destroy cycle, gtk_widget_destroy() will be called twice for popover. We might get around this by adding a child type="popover" or something for GtkMenuButton.
why would your widget destroy the popover ? Are you assigning it with gtk_widget_class_bind_template_child ?
(In reply to comment #1) > why would your widget destroy the popover ? Are you assigning it with > gtk_widget_class_bind_template_child ? That's correct. I need access to the popover so that can make some adjustments to it from the parent widget. (In particular, GtkMenuButton overrides "relative-to" when setting "popover", so have to fix that in code after loading the template to match the Builder search mockups).
Not seeing this in my test here. A testcase would help. But anyway, is this causing you a problem ? destroy handlers are typically written to be safe against being run twice.
The test case for us in Builder is GbSearchBox (global search). We have a popover attached to a GtkMenuButton (with the down arrow), but we want the popover arrow to point at the GtkSearchEntry. Doing this in data/ui/gb-search-box.ui like such: <object class="GtkPopover" id="popover"> <property name="visible">true</property> <property name="modal">false</property> <property name="relative-to">entry</property> results in the arrow still pointing at the menubutton. So in src/search/gb-search-box.c:337 (in ::constructed) we call: gtk_popover_set_relative_to (self->popover, GTK_WIDGET (self->entry)); Simply commenting out the above line results in the popover connected to the wrong widget despite being set in the ui definition.
We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO if they haven't seen activity in more than a year. If this issue is still important to you and still relevant with GTK+ 3.22 or master, please reopen it and we will migrate it to gitlab.
As announced a while ago, we are migrating to gitlab, and bugs that haven't seen activity in the last year or so will be not be migrated, but closed out in bugzilla. If this bug is still relevant to you, you can open a new issue describing the symptoms and how to reproduce it with gtk 3.22.x or master in gitlab: https://gitlab.gnome.org/GNOME/gtk/issues/new