diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2020-07-28 16:41:44 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2020-07-28 16:49:13 +0100 |
commit | bf06cad5d9d147fc9b5bc87d8166ead776f947f0 (patch) | |
tree | 952fb7c72a2e8f0012527414e3c9bcf558d221d2 /gtk/gtktestatcontext.c | |
parent | 2e8de6bd88131209ccd38e1f9dacdc3bb0b0f85b (diff) | |
download | gtk+-bf06cad5d9d147fc9b5bc87d8166ead776f947f0.tar.gz |
a11y: Add proper error reporting to value collection
We're currently overloading NULL to mean both "this value is undefined,
and should be reset to its default" and "the value collection failed".
Let's do error reporting right, by using GError to mean "the collection
failed, for this specific reason"; then, we can use a NULL return value
to signal that the accessible attribute should be reset to its default
value.
This is only relevant for pointer-sized attribute values: strings,
references, and reference lists; numeric, boolean, tristate, and token
values either cannot be undefined, or have a specific "undefined" value.
Diffstat (limited to 'gtk/gtktestatcontext.c')
-rw-r--r-- | gtk/gtktestatcontext.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/gtk/gtktestatcontext.c b/gtk/gtktestatcontext.c index f6c401b339..ff0b6833fd 100644 --- a/gtk/gtktestatcontext.c +++ b/gtk/gtktestatcontext.c @@ -161,13 +161,16 @@ gtk_test_accessible_check_property (GtkAccessible *accessible, va_start (args, property); + GError *error = NULL; GtkAccessibleValue *check_value = - gtk_accessible_value_collect_for_property (property, &args); + gtk_accessible_value_collect_for_property (property, &error, &args); va_end (args); + g_assert_no_error (error); + if (check_value == NULL) - return g_strdup ("undefined"); + check_value = gtk_accessible_value_get_default_for_property (property); GtkATContext *context = gtk_accessible_get_at_context (accessible); GtkAccessibleValue *real_value = @@ -220,13 +223,16 @@ gtk_test_accessible_check_state (GtkAccessible *accessible, va_start (args, state); + GError *error = NULL; GtkAccessibleValue *check_value = - gtk_accessible_value_collect_for_state (state, &args); + gtk_accessible_value_collect_for_state (state, &error, &args); va_end (args); + g_assert_no_error (error); + if (check_value == NULL) - return g_strdup ("undefined"); + check_value = gtk_accessible_value_get_default_for_state (state); GtkATContext *context = gtk_accessible_get_at_context (accessible); GtkAccessibleValue *real_value = @@ -279,13 +285,16 @@ gtk_test_accessible_check_relation (GtkAccessible *accessible, va_start (args, relation); + GError *error = NULL; GtkAccessibleValue *check_value = - gtk_accessible_value_collect_for_relation (relation, &args); + gtk_accessible_value_collect_for_relation (relation, &error, &args); va_end (args); + g_assert_no_error (error); + if (check_value == NULL) - return g_strdup ("undefined"); + check_value = gtk_accessible_value_get_default_for_relation (relation); GtkATContext *context = gtk_accessible_get_at_context (accessible); GtkAccessibleValue *real_value = |