stack: Don't recreate at contexts in dispose

This is the same protection we have in
GtkWidgetAccessible.
This commit is contained in:
Matthias Clasen 2023-03-03 08:44:29 -05:00 committed by Emmanuele Bassi
parent 500128d186
commit 611788fb53

View File

@ -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);