Re: [g-a-devel]Patch for at-poke



I have reworked the patch.

Padraig

> Subject: Re: [g-a-devel]Patch for at-poke
> To: "Padraig O'Briain" <Padraig Obriain sun com>
> Cc: accessibility mailing list <gnome-accessibility-devel gnome org>
> Mime-Version: 1.0
> Content-Transfer-Encoding: 7bit
> 
> Hi Padraig,
> 
> On Wed, 2002-10-02 at 13:21, Padraig O'Briain wrote:
> 
> > I have noticed that at-poke does not deregister the global event
> > listeners which it has registered.
> >
> > The attached patch does this deregistration.
> 
> 	Unreffing an object you don't own, and to which we keep a static
> pointer elsewhere seems like a bad move to me.
> 
> 	How about a new accessible_listener_shutdown method ?
> 
> 	Thanks,
> 
> 		Michael.
> 
> -- 
>  mmeeks gnu org  <><, Pseudo Engineer, itinerant idiot
> 
Index: accessible-listener.h
===================================================================
RCS file: /cvs/gnome/at-poke/src/accessible-listener.h,v
retrieving revision 1.1
diff -u -p -r1.1 accessible-listener.h
--- accessible-listener.h	15 May 2002 14:35:28 -0000	1.1
+++ accessible-listener.h	3 Oct 2002 12:48:36 -0000
@@ -31,5 +31,6 @@ typedef struct {
 AccessibleListener *accessible_listener_get         (void);
 void accessible_listener_set_target (AccessibleListener *al,
 				     Accessible *accessible);
+void accessible_listener_shutdown   (void);
 
 #endif /* ACCESSIBLE_LISTENER_H */
Index: accessible-listener.c
===================================================================
RCS file: /cvs/gnome/at-poke/src/accessible-listener.c,v
retrieving revision 1.1
diff -u -p -r1.1 accessible-listener.c
--- accessible-listener.c	15 May 2002 14:35:28 -0000	1.1
+++ accessible-listener.c	3 Oct 2002 12:48:36 -0000
@@ -7,6 +7,7 @@
  *
  * Copyright 2002 Sun Microsystems, Inc.
  */
+#include <string.h>
 #include "accessible-listener.h"
 #include <libgnome/gnome-macros.h>
 
@@ -29,6 +30,8 @@ static gchar *event_names[8] = {
 	NULL
 };
 
+static AccessibleListener *listener = NULL;
+
 GType accessible_listener_get_type (void);
 
 GNOME_CLASS_BOILERPLATE (AccessibleListener,
@@ -126,8 +129,6 @@ accessible_listener_class_init (Accessib
 AccessibleListener *
 accessible_listener_get (void)
 {
-	static AccessibleListener *listener = NULL;
-
 	if (!listener)
 		listener = g_object_new (
 			accessible_listener_get_type (), NULL);
@@ -140,4 +141,13 @@ accessible_listener_set_target (Accessib
 				Accessible *accessible)
 {
 	al->target = accessible;
+}
+
+void
+accessible_listener_shutdown (void)
+{
+	if (listener) {
+		g_object_unref (listener);
+		listener = NULL;
+	}	
 }
Index: main.c
===================================================================
RCS file: /cvs/gnome/at-poke/src/main.c,v
retrieving revision 1.15
diff -u -p -r1.15 main.c
--- main.c	24 Sep 2002 13:14:48 -0000	1.15
+++ main.c	3 Oct 2002 12:48:36 -0000
@@ -25,6 +25,7 @@
 
 #include "graphics.h"
 #include "child-listener.h"
+#include "accessible-listener.h"
 
 extern void poke (Accessible *accessible);
 extern Accessible *get_accessible_at_index (GtkListStore *list_store, int i);
@@ -357,6 +358,10 @@ application_window (void)
 	g_object_unref (app_xml);
 	g_free (app_window);
 	g_object_unref (cl);
+	/*
+	 * Deregister listeners which have been registered.
+	 */
+	accessible_listener_shutdown ();
 }
 
 static gboolean


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