GNOME Bugzilla – Bug 771812
Crash when reparenting a popover with a non-null parent_scrollable
Last modified: 2016-09-29 10:49:28 UTC
GtkPopover is causing a crash after adding it to a widget hierarchy as a descendant of a GtkScrollable, then moving it to a different widget hierarchy such that it isn't a descendant of a GtkScrollable, and the parent of the GtkScrollable is subsequently destroyed. The result of all this is in _gtk_popover_update_child_visible() after the line: > parent = gtk_widget_get_parent (GTK_WIDGET (priv->parent_scrollable)); `parent` is null, which is then passed as the second arg to gtk_widget_translate_coordinates(), which causes a segfault. The latter probably shouldn't segfault, but the former probably should be checking that the parent is not null. Also, the popover might want to use a better method to determine when its parent_scrollable is no longer valid. This is currently occurring in Geary, where we have an in-conversation email composer widget with a GtkMenuButton using a popover, and the user detaches the composer. This causes the composer+popover to be removed from the scrollable conversation hierarchy and added to a new top level window. Minimal test case to follow.
Created attachment 336056 [details] Minimal test case Compile with: > gcc -g `pkg-config --cflags gtk+-3.0` gtk_menu_button_popover_crash.c -o gtk_menu_button_popover_crash `pkg-config --libs gtk+-3.0` It will crash as soon as you run it with an indicative stack trace.
Created attachment 336466 [details] [review] popover: Add helper functions around setting up an scrollable gtk_popover_set_scrollable_full() takes care of the signal connected on the scrollable itself, in addition to the adjustment signals the popover listens to. gtk_popover_update_scrollable() looks up the current relative-to widget hierarchy and updates the current scrollable. The places where the scrollable is being maintained have been updated to use these functions.
Created attachment 336467 [details] [review] popover: Update scrollable on relative-to hierarchy changes The relative-to widget may be reparented itself into/out of a scrollable. In this cases make the hierachy-changed handler to unset the parent scrollable when unparented, and look up again the parent scrollable after it's reparented.
Review of attachment 336466 [details] [review]: sure
Review of attachment 336467 [details] [review]: ok
Attachment 336466 [details] pushed as 588a1dc - popover: Add helper functions around setting up an scrollable Attachment 336467 [details] pushed as 769ee11 - popover: Update scrollable on relative-to hierarchy changes