diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c index 0975ecf472..59a3a0357b 100644 --- a/gtk/gtkstack.c +++ b/gtk/gtkstack.c @@ -219,6 +219,7 @@ struct _GtkStackPage guint needs_attention : 1; guint visible : 1; guint use_underline : 1; + guint in_destruction : 1; }; typedef struct _GtkStackPageClass GtkStackPageClass; @@ -235,6 +236,14 @@ gtk_stack_page_accessible_get_at_context (GtkAccessible *accessible) { GtkStackPage *page = GTK_STACK_PAGE (accessible); + if (page->in_destruction) + { + GTK_DEBUG (A11Y, "ATContext for ā€œ%sā€ [%p] accessed during destruction", + G_OBJECT_TYPE_NAME (accessible), + accessible); + return NULL; + } + if (page->at_context == NULL) { GtkAccessibleRole role = GTK_ACCESSIBLE_ROLE_TAB_PANEL; @@ -353,6 +362,8 @@ gtk_stack_page_dispose (GObject *object) { GtkStackPage *page = GTK_STACK_PAGE (object); + page->in_destruction = TRUE; + g_clear_object (&page->at_context); G_OBJECT_CLASS (gtk_stack_page_parent_class)->dispose (object);