[at-spi2-atk] Avoid calling g_error and aborting the application on some errors



commit 1679785bff78813119a9c55c2e3ce2154dafb473
Author: Mike Gorse <mgorse novell com>
Date:   Sun Mar 14 08:49:24 2010 -0400

    Avoid calling g_error and aborting the application on some errors

 atk-adaptor/bridge.c |   28 ++++++++++++++++++++++------
 droute/droute.c      |    5 ++++-
 2 files changed, 26 insertions(+), 7 deletions(-)
---
diff --git a/atk-adaptor/bridge.c b/atk-adaptor/bridge.c
index 45bc15f..a2ab66c 100644
--- a/atk-adaptor/bridge.c
+++ b/atk-adaptor/bridge.c
@@ -158,7 +158,7 @@ spi_atk_bridge_get_bus (void)
 
 /*---------------------------------------------------------------------------*/
 
-static void
+static gboolean
 register_application (SpiBridge * app)
 {
   DBusMessage *message, *reply;
@@ -188,12 +188,21 @@ register_application (SpiBridge * app)
       dbus_message_iter_init (reply, &iter);
       dbus_message_iter_recurse (&iter, &iter_struct);
       if (!(dbus_message_iter_get_arg_type (&iter_struct) == DBUS_TYPE_STRING))
-            g_error ("AT-SPI: Could not obtain desktop path or name\n");
+        {
+          g_warning ("AT-SPI: Could not obtain desktop path or name\n");
+          return FALSE;
+        }
       dbus_message_iter_get_basic (&iter_struct, &app_name);
       if (!dbus_message_iter_next (&iter_struct))
-            g_error ("AT-SPI: Could not obtain desktop name");
+        {
+          g_warning ("AT-SPI: Could not obtain desktop name");
+          return FALSE;
+        }
       if (!(dbus_message_iter_get_arg_type (&iter_struct) == DBUS_TYPE_OBJECT_PATH))
-            g_error ("AT-SPI: Could not obtain desktop path");
+        {
+          g_warning ("AT-SPI: Could not obtain desktop path");
+          return FALSE;
+        }
       dbus_message_iter_get_basic (&iter_struct, &obj_path);
 
       app->desktop_name = g_strdup (app_name);
@@ -201,9 +210,10 @@ register_application (SpiBridge * app)
     }
   else
     {
-      g_error ("AT-SPI: Could not embed inside desktop: %s\n", error.message);
+      g_warning ("AT-SPI: Could not embed inside desktop: %s\n", error.message);
+      return FALSE;
     }
-
+  return TRUE;
 }
 
 /*---------------------------------------------------------------------------*/
@@ -414,6 +424,12 @@ adaptor_init (gint * argc, gchar ** argv[])
   treepath = droute_add_one (spi_global_app_data->droute,
                              "/org/at_spi/cache", spi_global_cache);
 
+  if (!treepath)
+    {
+      g_warning ("atk-bridge: Error in droute_add_one().  Already running?");
+      return 0;
+    }
+
   accpath = droute_add_many (spi_global_app_data->droute,
                              "/org/a11y/atspi/accessible",
                              NULL,
diff --git a/droute/droute.c b/droute/droute.c
index f0b4f00..e2534e1 100644
--- a/droute/droute.c
+++ b/droute/droute.c
@@ -174,7 +174,10 @@ droute_add_one (DRouteContext *cnx,
 
     registered = dbus_connection_register_object_path (cnx->bus, path, &droute_vtable, new_path);
     if (!registered)
-        oom();
+      {
+        path_free (new_path, NULL);
+        return NULL;
+      }
 
     g_ptr_array_add (cnx->registered_paths, new_path);
     return new_path;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]