GNOME Bugzilla – Bug 766323
GTKPopover gives warnings if visible when reparented
Last modified: 2016-08-05 13:14:40 UTC
In my application Terminix I use a popover with buttons on it to allow users to split the terminal. This causes Terminix to remove the existing terminal, drop down a GTKPaned and then re-parent the terminal to the GTKPaned plus add a new terminal. When triggered from a popover, the following error messages are generated: (terminix:4015): Gtk-CRITICAL **: gtk_window_get_default_widget: assertion 'GTK_IS_WINDOW (window)' failed (terminix:4015): Gtk-CRITICAL **: gtk_window_set_default: assertion 'GTK_IS_WINDOW (window)' failed Looking at the source code in gtkpopover, I can see that these methods are called in the popover unmap/map events. I realize my situation is an edge case, but should this code explicitly check the validity of the window before calling gtk_window_get_default_widget and gtk_window_set_default?
Also, any tips to workaround this message? While it's not critical, I'm working towards getting my app to a stable 1.0 release next week and I would love to get it running clean, this is the only GTK message I have left to resolve. So far I have tried: a. Hiding the popover b. Hiding the popover and processing messages via Main.eventsPending>Main.iterationDo c. Hiding the popover and deferring executing the action via an addIdle No success with any of these.
Created attachment 327802 [details] [review] popver: Check for priv->window before using it It gets possibly set to NULL in a few places, so check for it before trying to use it, like the rest of the code does.
To the reporter, it'd be great if you could attach a backtrace with debugging symbols of that first warning (e.g. running with G_DEBUG=fatal-criticals). Those are code paths I don't expect at all while the popover is unparented.
Comment on attachment 327802 [details] [review] popver: Check for priv->window before using it The patch looks alright to me as a paranoia check (Perhaps could clear too the prev_default when priv->window gets NULL in _gtk_popover_parent_hierarchy_changed()). However seems to be addressing the symptom, I'll wait to have more info before marking it a-c-n.
As requested: (terminix:6122): Gtk-CRITICAL **: gtk_window_get_default_widget: assertion 'GTK_IS_WINDOW (window)' failed Thread 1 "terminix" received signal SIGTRAP, Trace/breakpoint trap. 0x00007ffff6c3670b in g_logv () from /usr/lib/libglib-2.0.so.0 (gdb) bt
+ Trace 236271
Thanks for the backtrace, also got a testcase kindly provided by Timm. I'm pushing a fix to master/gtk-3-20.
The following fix has been pushed: 76a5e3f popover: set priv->window before setting doing add_popover() on it
Created attachment 328320 [details] [review] popover: set priv->window before setting doing add_popover() on it If the popover's relative-to widget is unparented/reparented, we end up unparenting/reparenting the popover as well. In that case, at the moment of reparenting, the widget might have been visible (and is thus mapped again), but priv->window hasn't been set yet. We must first set priv->window, and then call gtk_window_add_popover(), that way gtk_popover_map() has its prerequisites straight.
Thank you both for your work on this, much appreciated.
*** Bug 769547 has been marked as a duplicate of this bug. ***