From: Michael Catanzaro Date: Wed, 23 Aug 2023 20:51:08 +0000 (-0500) Subject: notebook: fix critical when switching page X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2^2~6 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=2e2857df325d91df91a8672d80846e39c3924e20;p=gtk4.git notebook: fix critical when switching page It's expected that gtk_widget_get_root() will return NULL if the widget tree does not contain a root widget. I don't know what that means or why it happens, but it's true in gnome-control-center's network panel when displaying the OpenVPN configuration dialog. We need to handle it. Fixes #6056 --- diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index d326516add..9ea880fb08 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -5409,7 +5409,9 @@ gtk_notebook_real_switch_page (GtkNotebook *notebook, if (notebook->cur_page) { GtkRoot *root = gtk_widget_get_root (GTK_WIDGET (notebook)); - GtkWidget *focus = gtk_root_get_focus (root); + GtkWidget *focus = NULL; + if (root) + focus = gtk_root_get_focus (root); if (focus) child_has_focus = gtk_widget_is_ancestor (focus, notebook->cur_page->child); gtk_widget_unset_state_flags (notebook->cur_page->tab_widget, GTK_STATE_FLAG_CHECKED);