2002-03-19 Michael Meeks <michael@ximian.com>
authormichael <michael@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Tue, 19 Mar 2002 22:31:47 +0000 (22:31 +0000)
committermichael <michael@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Tue, 19 Mar 2002 22:31:47 +0000 (22:31 +0000)
* registryd/registry.c (desktop_remove_application),
(desktop_add_application): clean coding style.

* registryd/desktop.c (spi_desktop_remove_application),
(spi_desktop_add_application): kill re-enterency hazards.
(spi_desktop_dispose): remove bogus redundant cast
obscuring bug; fix bug too.
(spi_desktop_init): make the desktop object immortal.

git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@260 e2bd861d-eb25-0410-b326-f6ed22b6b98c

ChangeLog
registryd/desktop.c
registryd/registry.c
registryd/registryd.c

index f7eb4a8..4bd5501 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2002-03-19  Michael Meeks  <michael@ximian.com>
+
+       * registryd/registry.c (desktop_remove_application),
+       (desktop_add_application): clean coding style.
+
+       * registryd/desktop.c (spi_desktop_remove_application),
+       (spi_desktop_add_application): kill re-enterency hazards.
+       (spi_desktop_dispose): remove bogus redundant cast
+       obscuring bug; fix bug too.
+       (spi_desktop_init): make the desktop object immortal.
+
 2002-03-16 Bill Haneman <bill.haneman@sun.com>
 
        * test/simple-at.c:
index 06f688b..929a25e 100644 (file)
@@ -53,6 +53,7 @@ spi_desktop_init (SpiDesktop *desktop)
   spi_base_construct (SPI_BASE (desktop), g_object_new (ATK_TYPE_OBJECT, NULL));
 
   desktop->applications = NULL;
+  bonobo_object_set_immortal (BONOBO_OBJECT (desktop), TRUE);
 
   atk_object_set_name (ATK_OBJECT (SPI_BASE (desktop)->gobj), "main");
 }
@@ -64,7 +65,8 @@ spi_desktop_dispose (GObject *object)
 
   while (desktop->applications)
     {
-      Application *app = (Application *) desktop->applications;
+      Application *app = desktop->applications->data;
+      g_assert (app->ref != CORBA_OBJECT_NIL);
       spi_desktop_remove_application (desktop, app->ref);
     }
 
@@ -191,10 +193,13 @@ spi_desktop_add_application (SpiDesktop *desktop,
       app->ref = ref;
 
       desktop->applications = g_list_append (desktop->applications, app);
-      g_signal_emit (G_OBJECT (desktop), spi_desktop_signals[APPLICATION_ADDED], 0,
-                    g_list_index (desktop->applications, app));
 
-      ORBit_small_listen_for_broken (app->ref, G_CALLBACK (abnormal_application_termination), app);
+      ORBit_small_listen_for_broken (
+             app->ref, G_CALLBACK (abnormal_application_termination), app);
+
+      g_signal_emit (G_OBJECT (desktop),
+                    spi_desktop_signals[APPLICATION_ADDED], 0,
+                    g_list_index (desktop->applications, app));
     }
 
   CORBA_exception_free (&ev);
@@ -204,13 +209,16 @@ void
 spi_desktop_remove_application (SpiDesktop *desktop,
                                const Accessibility_Application app_ref)
 {
+  guint idx;
   GList *l;
   CORBA_Environment ev;
 
+  g_return_if_fail (app_ref != CORBA_OBJECT_NIL);
   g_return_if_fail (SPI_IS_DESKTOP (desktop));
 
   CORBA_exception_init (&ev);
 
+  idx = 0;
   for (l = desktop->applications; l; l = l->next)
     {
       Application *app = (Application *) l->data;
@@ -219,6 +227,7 @@ spi_desktop_remove_application (SpiDesktop *desktop,
         {
          break;
        }
+      idx++;
     }
 
   CORBA_exception_free (&ev);
@@ -227,12 +236,12 @@ spi_desktop_remove_application (SpiDesktop *desktop,
     {
       Application *app = (Application *) l->data;
 
-      g_signal_emit (G_OBJECT (desktop), spi_desktop_signals[APPLICATION_REMOVED], 0,
-                    g_list_index (desktop->applications, l));
       desktop->applications = g_list_delete_link (desktop->applications, l);
 
       ORBit_small_unlisten_for_broken (app->ref, G_CALLBACK (abnormal_application_termination));
       bonobo_object_release_unref (app->ref, NULL);
       g_free (app);
+      
+      g_signal_emit (G_OBJECT (desktop), spi_desktop_signals[APPLICATION_REMOVED], 0, idx);
     }
 }
index 1bd0fb2..466489b 100644 (file)
@@ -86,7 +86,7 @@ static void
 desktop_add_application (SpiDesktop *desktop,
                         guint index, gpointer data)
 {
-  BonoboObject *registry = BONOBO_OBJECT(data);
+  BonoboObject *registry = BONOBO_OBJECT (data);
   Accessibility_Event e;
   CORBA_Environment ev;
   
@@ -95,7 +95,7 @@ desktop_add_application (SpiDesktop *desktop,
   e.detail1 = index;
   e.detail2 = 0;
   CORBA_exception_init (&ev);
-  Accessibility_Registry_notifyEvent (BONOBO_OBJREF(registry),
+  Accessibility_Registry_notifyEvent (BONOBO_OBJREF (registry),
                                      &e, &ev);
   CORBA_exception_free (&ev);
 }
@@ -106,7 +106,7 @@ static void
 desktop_remove_application (SpiDesktop *desktop,
                            guint index, gpointer data)
 {
-  BonoboObject *registry = BONOBO_OBJECT(data);
+  BonoboObject *registry = BONOBO_OBJECT (data);
   Accessibility_Event e;
   CORBA_Environment ev;
   
@@ -115,7 +115,7 @@ desktop_remove_application (SpiDesktop *desktop,
   e.detail1 = index;
   e.detail2 = 0;
   CORBA_exception_init (&ev);
-  Accessibility_Registry_notifyEvent (BONOBO_OBJREF(registry),
+  Accessibility_Registry_notifyEvent (BONOBO_OBJREF (registry),
                                      &e, &ev);
   CORBA_exception_free (&ev);
 }
@@ -661,10 +661,15 @@ spi_registry_init (SpiRegistry *registry)
   registry->toolkit_listeners = NULL;
   registry->desktop = spi_desktop_new ();
   /* Register callback notification for application addition and removal */
-  g_signal_connect (G_OBJECT (registry->desktop), "application_added",
-                           G_CALLBACK(desktop_add_application), (gpointer)registry);
-  g_signal_connect (G_OBJECT (registry->desktop), "application_removed",
-                           G_CALLBACK(desktop_remove_application), (gpointer)registry);
+  g_signal_connect (G_OBJECT (registry->desktop),
+                   "application_added",
+                   G_CALLBACK (desktop_add_application),
+                   registry);
+
+  g_signal_connect (G_OBJECT (registry->desktop),
+                   "application_removed",
+                   G_CALLBACK (desktop_remove_application),
+                   registry);
 
   registry->de_controller = NULL;
 }
index c3f5509..228b474 100644 (file)
@@ -35,6 +35,8 @@ main (int argc, char **argv)
   char        *obj_id;
   SpiRegistry *registry;
 
+  free (malloc (8)); /* -lefence */
+
   if (!bonobo_init (&argc, argv))
     {
       g_error ("Could not initialize oaf / Bonobo");