reentrancy in impl_Bonobo_Control_activate()



impl_Bonobo_Control_activate() doesn't like to be reentered. 

on the frame side, if you call: 

    bonobo_control_frame_control_activate (f); 
    bonobo_control_frame_control_deactivate (f); 
    
and the right automerge bits are on, you will end up with the toolbars
merged. 

the attached patch fixes this. 

jacob 
-- 
"In fact, can you imagine anything more terrifying than a zombie clown?"
	-- moby
Index: bonobo-control.c
===================================================================
RCS file: /cvs/gnome/libbonoboui/bonobo/bonobo-control.c,v
retrieving revision 1.117
diff -u -r1.117 bonobo-control.c
--- bonobo-control.c	2001/12/31 11:55:50	1.117
+++ bonobo-control.c	2002/01/04 00:08:28
@@ -155,8 +155,13 @@
 	if (remote_container == CORBA_OBJECT_NIL)
 		return;
 
-	bonobo_ui_component_set_container (
-		control->priv->ui_component, remote_container, NULL);
+	/*
+	 * we could have been re-entereted in the previous call, so
+	 * make sure we are still active
+	 */
+	if (control->priv->active)
+		bonobo_ui_component_set_container (
+			control->priv->ui_component, remote_container, NULL);
 
 	bonobo_object_release_unref (remote_container, NULL);
 }
@@ -177,18 +182,33 @@
 			      CORBA_Environment *ev)
 {
 	BonoboControl *control = BONOBO_CONTROL (bonobo_object_from_servant (servant));
+	gboolean old_activated;
 
-	if (control->priv->automerge && control->priv->active != activated) {
+	if (activated == control->priv->active)
+		return;
+	
+	/* 
+	 * store the old activated value as we can be re-entered
+	 * during (un)merge
+	 */
+	old_activated = control->priv->active;
+	control->priv->active = activated;
+
+	if (control->priv->automerge) {
 		if (activated)
 			bonobo_control_auto_merge (control);
 		else
 			bonobo_control_auto_unmerge (control);
 	}
 
+	/* 
+	 * if our active state is not what we are changing it to, then
+	 * don't emit the signal
+	 */
 	if (control->priv->active != activated)
-		g_signal_emit (G_OBJECT (control), control_signals [ACTIVATE], 0, (gboolean) activated);
+		return;
 
-	control->priv->active = activated;
+	g_signal_emit (G_OBJECT (control), control_signals [ACTIVATE], 0, (gboolean) activated);
 }
 
 static void


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