bonobo-listener refcounting fix



Add some refs to prevent objects from being destroyed at inopportune
times.

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/bonobo/ChangeLog,v
retrieving revision 1.958
diff -u -r1.958 ChangeLog
--- ChangeLog	2001/02/13 18:59:26	1.958
+++ ChangeLog	2001/02/13 21:23:57
@@ -1,3 +1,19 @@
+2001-02-13  Dan Winship  <danw ximian com>
+
+	* bonobo/bonobo-listener.c (impl_Bonobo_Listener_event): ref the
+	listener through this function so that if the callback unrefs it
+	the signal emission won't crash.
+
+	* bonobo/bonobo-event-source.c
+	(bonobo_event_source_notify_listeners): ref the event source
+	around the notifications in case the last listener unregisters
+	itself from its notification function.
+
+	* bonobo/bonobo-control.c (impl_Bonobo_Control_setWindowId): Use
+	gtk_signal_connect_while_alive so we don't try to destroy the
+	control on both the "destroy_event" and "destroy" signals from the
+	plug.
+
 2001-02-13  Darin Adler  <darin eazel com>
 
 	* .cvsignore: Fix for recent xml-i18n-tools.
Index: bonobo/bonobo-listener.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-listener.c,v
retrieving revision 1.16
diff -u -r1.16 bonobo-listener.c
--- bonobo/bonobo-listener.c	2001/02/08 23:37:42	1.16
+++ bonobo/bonobo-listener.c	2001/02/13 21:23:57
@@ -39,6 +39,7 @@
 
 	listener = BONOBO_LISTENER (bonobo_object_from_servant (servant));
 
+	bonobo_object_ref (BONOBO_OBJECT (listener));
 	if (listener->priv->event_callback) 
 		listener->priv->event_callback (
 			listener, (CORBA_char *) event_name, 
@@ -49,6 +50,7 @@
 	gtk_signal_emit (GTK_OBJECT (listener),
 			 signals [EVENT_NOTIFY],
 			 event_name, args, ev);
+	bonobo_object_unref (BONOBO_OBJECT (listener));
 }
 
 static void
Index: bonobo/bonobo-event-source.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-event-source.c,v
retrieving revision 1.18
diff -u -r1.18 bonobo-event-source.c
--- bonobo/bonobo-event-source.c	2001/02/08 23:37:42	1.18
+++ bonobo/bonobo-event-source.c	2001/02/13 21:23:57
@@ -162,6 +162,7 @@
 	} else
 		my_ev = opt_ev;
 
+	bonobo_object_ref (BONOBO_OBJECT (event_source));
 	for (list = event_source->priv->listeners; list; list = list->next) {
 		ListenerDesc *desc = (ListenerDesc *) list->data;
 
@@ -170,6 +171,7 @@
 			Bonobo_Listener_event (desc->listener, 
 					       event_name, value, my_ev);
 	}
+	bonobo_object_unref (BONOBO_OBJECT (event_source));
 	
 	if (!opt_ev)
 		CORBA_exception_free (&ev);




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