[at-spi2-core] Return exceptions for errors rather than printing warnings
- From: Mike Gorse <mgorse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [at-spi2-core] Return exceptions for errors rather than printing warnings
- Date: Tue, 4 Jan 2011 18:02:00 +0000 (UTC)
commit e1909af6050686754cd4fa43aa61859c084f6e11
Author: Mike Gorse <mgorse novell com>
Date: Tue Jan 4 12:04:12 2011 -0600
Return exceptions for errors rather than printing warnings
atspi/atspi-accessible.c | 22 ++++++++++++++--------
atspi/atspi-collection.c | 2 +-
atspi/atspi-misc-private.h | 14 ++++++++++++--
atspi/atspi-misc.c | 10 ++++++++--
atspi/atspi-text.c | 4 ++--
5 files changed, 37 insertions(+), 15 deletions(-)
---
diff --git a/atspi/atspi-accessible.c b/atspi/atspi-accessible.c
index ede8b87..aa31965 100644
--- a/atspi/atspi-accessible.c
+++ b/atspi/atspi-accessible.c
@@ -509,7 +509,9 @@ atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
g_return_val_if_fail (obj != NULL, NULL);
reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetRelationSet", error, "");
- _ATSPI_DBUS_CHECK_SIG (reply, "a(ua(so))", NULL);
+ if (!reply)
+ return NULL;
+ _ATSPI_DBUS_CHECK_SIG (reply, "a(ua(so))", error, NULL);
ret = g_array_new (TRUE, TRUE, sizeof (AtspiRelation *));
dbus_message_iter_init (reply, &iter);
@@ -607,6 +609,14 @@ atspi_accessible_get_localized_role_name (AtspiAccessible *obj, GError **error)
return retval;
}
+static AtspiStateSet *
+defunct_set ()
+{
+ AtspiStateSet *set = atspi_state_set_new (NULL);
+ atspi_state_set_add (set, ATSPI_STATE_DEFUNCT);
+ return set;
+}
+
/**
* atspi_accessible_get_state_set:
* @obj: a pointer to the #AtspiAccessible object on which to operate.
@@ -620,11 +630,7 @@ AtspiStateSet *
atspi_accessible_get_state_set (AtspiAccessible *obj)
{
if (!obj->parent.app || !obj->parent.app->bus)
- {
- AtspiStateSet *set = atspi_state_set_new (NULL);
- atspi_state_set_add (set, ATSPI_STATE_DEFUNCT);
- return set;
- }
+ return defunct_set ();
if (!(obj->cached_properties & ATSPI_CACHE_STATES))
@@ -633,7 +639,7 @@ atspi_accessible_get_state_set (AtspiAccessible *obj)
DBusMessageIter iter;
reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
"GetState", NULL, "");
- _ATSPI_DBUS_CHECK_SIG (reply, "au", NULL);
+ _ATSPI_DBUS_CHECK_SIG (reply, "au", NULL, defunct_set ());
dbus_message_iter_init (reply, &iter);
_atspi_dbus_set_state (obj, &iter);
dbus_message_unref (reply);
@@ -1201,7 +1207,7 @@ _atspi_accessible_is_a (AtspiAccessible *accessible,
DBusMessageIter iter;
reply = _atspi_dbus_call_partial (accessible, atspi_interface_accessible,
"GetInterfaces", NULL, "");
- _ATSPI_DBUS_CHECK_SIG (reply, "as", FALSE);
+ _ATSPI_DBUS_CHECK_SIG (reply, "as", NULL, FALSE);
dbus_message_iter_init (reply, &iter);
_atspi_dbus_set_interfaces (accessible, &iter);
dbus_message_unref (reply);
diff --git a/atspi/atspi-collection.c b/atspi/atspi-collection.c
index 144def5..29f68fa 100644
--- a/atspi/atspi-collection.c
+++ b/atspi/atspi-collection.c
@@ -83,7 +83,7 @@ return_accessibles (DBusMessage *message)
DBusMessageIter iter, iter_array;
GArray *ret = g_array_new (TRUE, TRUE, sizeof (AtspiAccessible *));
- _ATSPI_DBUS_CHECK_SIG (message, "a(so)", NULL);
+ _ATSPI_DBUS_CHECK_SIG (message, "a(so)", NULL, NULL);
dbus_message_iter_init (message, &iter);
dbus_message_iter_recurse (&iter, &iter_array);
diff --git a/atspi/atspi-misc-private.h b/atspi/atspi-misc-private.h
index 4814719..52ba2fd 100644
--- a/atspi/atspi-misc-private.h
+++ b/atspi/atspi-misc-private.h
@@ -147,11 +147,20 @@ void _atspi_dbus_set_interfaces (AtspiAccessible *accessible, DBusMessageIter *i
void _atspi_dbus_set_state (AtspiAccessible *accessible, DBusMessageIter *iter);
-#define _ATSPI_DBUS_CHECK_SIG(message, type, ret) \
+#define _ATSPI_DBUS_CHECK_SIG(message, type, error, ret) \
if (!message) { \
g_warning ("at-spi: Got no message at %s line %d\n", __FILE__, __LINE__); \
return (ret); \
} \
+ if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR) \
+ { \
+ const char *err; \
+ dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &err, DBUS_TYPE_INVALID); \
+ if (err) \
+ g_set_error_literal (error, ATSPI_ERROR, ATSPI_ERROR_IPC, err); \
+ dbus_message_unref (message); \
+ return ret; \
+ } \
if (strcmp (dbus_message_get_signature (message), type) != 0) \
{ \
g_warning ("at-spi: Expected message signature %s but got %s at %s line %d", type, dbus_message_get_signature (message), __FILE__, __LINE__); \
@@ -176,6 +185,7 @@ GQuark atspi_error_quark (void);
*/
typedef enum
{
- ATSPI_ERROR_APPLICATION_GONE
+ ATSPI_ERROR_APPLICATION_GONE,
+ ATSPI_ERROR_IPC
} AtspiError;
#endif /* _ATSPI_MISC_PRIVATE_H_ */
diff --git a/atspi/atspi-misc.c b/atspi/atspi-misc.c
index 2b62ff9..4bc3a78 100644
--- a/atspi/atspi-misc.c
+++ b/atspi/atspi-misc.c
@@ -1179,7 +1179,10 @@ _atspi_dbus_return_hash_from_message (DBusMessage *message)
DBusMessageIter iter;
GHashTable *ret;
- _ATSPI_DBUS_CHECK_SIG (message, "a{ss}", NULL);
+ if (!message)
+ return NULL;
+
+ _ATSPI_DBUS_CHECK_SIG (message, "a{ss}", NULL, NULL);
dbus_message_iter_init (message, &iter);
ret = _atspi_dbus_hash_from_iter (&iter);
@@ -1213,7 +1216,10 @@ _atspi_dbus_return_attribute_array_from_message (DBusMessage *message)
DBusMessageIter iter;
GArray *ret;
- _ATSPI_DBUS_CHECK_SIG (message, "a{ss}", NULL);
+ if (!message)
+ return NULL;
+
+ _ATSPI_DBUS_CHECK_SIG (message, "a{ss}", NULL, NULL);
dbus_message_iter_init (message, &iter);
diff --git a/atspi/atspi-text.c b/atspi/atspi-text.c
index 1044f1b..01fb539 100644
--- a/atspi/atspi-text.c
+++ b/atspi/atspi-text.c
@@ -170,7 +170,7 @@ atspi_text_get_attributes (AtspiText *obj,
return NULL;
reply = _atspi_dbus_call_partial (obj, atspi_interface_text, "GetAttributes", error, "i", d_offset);
- _ATSPI_DBUS_CHECK_SIG (reply, "a{ss}ii", ret)
+ _ATSPI_DBUS_CHECK_SIG (reply, "a{ss}ii", error, ret)
dbus_message_iter_init (reply, &iter);
ret = _atspi_dbus_hash_from_iter (&iter);
@@ -226,7 +226,7 @@ atspi_text_get_attribute_run (AtspiText *obj,
reply = _atspi_dbus_call_partial (obj, atspi_interface_text,
"GetAttributeRun", error, "ib", d_offset,
include_defaults);
- _ATSPI_DBUS_CHECK_SIG (reply, "a{ss}ii", ret)
+ _ATSPI_DBUS_CHECK_SIG (reply, "a{ss}ii", error, ret)
dbus_message_iter_init (reply, &iter);
ret = _atspi_dbus_hash_from_iter (&iter);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]