forked from AuroraMiddleware/gtk
a11y: Check whether a widget is mapped before querying its parent
Call gtk_widget_get_mapped() in a couple of places before looking at the widget's parent, since it might be set to a widget that has been finalized, causing an invalid read.
This commit is contained in:
parent
d7e07a8470
commit
7e3db6fdd3
@ -174,6 +174,9 @@ gtk_widget_accessible_get_parent (AtkObject *accessible)
|
|||||||
if (parent != NULL)
|
if (parent != NULL)
|
||||||
return parent;
|
return parent;
|
||||||
|
|
||||||
|
if (!gtk_widget_get_mapped (widget))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
parent_widget = gtk_widget_get_parent (widget);
|
parent_widget = gtk_widget_get_parent (widget);
|
||||||
if (parent_widget == NULL)
|
if (parent_widget == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -237,7 +240,7 @@ find_label (GtkWidget *widget)
|
|||||||
temp_widget = label;
|
temp_widget = label;
|
||||||
while (temp_widget)
|
while (temp_widget)
|
||||||
{
|
{
|
||||||
if (temp_widget == widget)
|
if (temp_widget == widget || !gtk_widget_get_mapped (temp_widget))
|
||||||
{
|
{
|
||||||
label = NULL;
|
label = NULL;
|
||||||
break;
|
break;
|
||||||
@ -271,7 +274,7 @@ gtk_widget_accessible_ref_relation_set (AtkObject *obj)
|
|||||||
label = find_label (widget);
|
label = find_label (widget);
|
||||||
if (label == NULL)
|
if (label == NULL)
|
||||||
{
|
{
|
||||||
if (GTK_IS_BUTTON (widget))
|
if (GTK_IS_BUTTON (widget) && gtk_widget_get_mapped (widget))
|
||||||
/*
|
/*
|
||||||
* Handle the case where GnomeIconEntry is the mnemonic widget.
|
* Handle the case where GnomeIconEntry is the mnemonic widget.
|
||||||
* The GtkButton which is a grandchild of the GnomeIconEntry
|
* The GtkButton which is a grandchild of the GnomeIconEntry
|
||||||
@ -293,7 +296,7 @@ gtk_widget_accessible_ref_relation_set (AtkObject *obj)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (GTK_IS_COMBO_BOX (widget))
|
else if (GTK_IS_COMBO_BOX (widget) && gtk_widget_get_mapped (widget))
|
||||||
/*
|
/*
|
||||||
* Handle the case when GtkFileChooserButton is the mnemonic
|
* Handle the case when GtkFileChooserButton is the mnemonic
|
||||||
* widget. The GtkComboBox which is a child of the
|
* widget. The GtkComboBox which is a child of the
|
||||||
@ -440,7 +443,7 @@ gtk_widget_accessible_get_index_in_parent (AtkObject *accessible)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GTK_IS_WIDGET (widget))
|
if (!GTK_IS_WIDGET (widget) || !gtk_widget_get_mapped (widget))
|
||||||
return -1;
|
return -1;
|
||||||
parent_widget = gtk_widget_get_parent (widget);
|
parent_widget = gtk_widget_get_parent (widget);
|
||||||
if (!GTK_IS_CONTAINER (parent_widget))
|
if (!GTK_IS_CONTAINER (parent_widget))
|
||||||
@ -781,6 +784,9 @@ gtk_widget_accessible_on_screen (GtkWidget *widget)
|
|||||||
|
|
||||||
gtk_widget_get_allocation (widget, &allocation);
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
|
||||||
|
if (!gtk_widget_get_mapped (widget))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
viewport = gtk_widget_get_ancestor (widget, GTK_TYPE_VIEWPORT);
|
viewport = gtk_widget_get_ancestor (widget, GTK_TYPE_VIEWPORT);
|
||||||
if (viewport)
|
if (viewport)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user