patch for bug in BonoboControl



I recently discovered that there's a bug in BonoboControl. It assumes that
the BonoboControlFrame is still around at destroy time. This means that if
you ref a BonoboControl and then unref the control frame, you run into
problems at BonoboControl unref time.

The fix is fairly simple, just make a setFrame call on the control when the
control frame is being deleted, just in case the unref call to the control
doesn't get rid of the last ref. I've enclosed a patch that I already mailed
to Michael, but I thought I should post it here for others to inspect.

My apologies for including the patch as an attachment. I had problems with
my mailer messing up line breaks.

    -- Darin

Index: bonobo/bonobo-control-frame.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-control-frame.c,v
retrieving revision 1.59
diff -p -u -r1.59 bonobo-control-frame.c
--- bonobo/bonobo-control-frame.c	2001/02/21 10:19:27	1.59
+++ bonobo/bonobo-control-frame.c	2001/03/07 22:48:11
@@ -336,8 +336,15 @@ bonobo_control_frame_destroy (GtkObject 
 
 	gtk_widget_destroy (control_frame->priv->container);
 
-	if (control_frame->priv->control != CORBA_OBJECT_NIL)
+	if (control_frame->priv->control != CORBA_OBJECT_NIL) {
+		CORBA_Environment ev;
+
+		CORBA_exception_init (&ev);
+		Bonobo_Control_setFrame (control_frame->priv->control,
+					 CORBA_OBJECT_NIL,&ev);
+		CORBA_exception_free (&ev);
 		bonobo_object_release_unref (control_frame->priv->control, NULL);
+	}
 	control_frame->priv->control = CORBA_OBJECT_NIL;
 
 	if (control_frame->priv->socket) {
Index: bonobo/bonobo-control.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-control.c,v
retrieving revision 1.71
diff -p -u -r1.71 bonobo-control.c
--- bonobo/bonobo-control.c	2001/02/23 21:25:17	1.71
+++ bonobo/bonobo-control.c	2001/03/07 22:48:12
@@ -635,11 +635,13 @@ bonobo_control_destroy (GtkObject *objec
 		bonobo_object_unref (BONOBO_OBJECT (control->priv->propbag));
 	control->priv->propbag = NULL;
 
-	if (control->priv->active)
-		Bonobo_ControlFrame_activated (control->priv->control_frame,
-					       FALSE, &ev);
-
-	CORBA_Object_release (control->priv->control_frame, &ev);
+	if (control->priv->control_frame != CORBA_OBJECT_NIL) {
+		if (control->priv->active)
+			Bonobo_ControlFrame_activated (control->priv->control_frame,
+						       FALSE, &ev);
+		
+		CORBA_Object_release (control->priv->control_frame, &ev);
+	}
 
 	CORBA_exception_free (&ev);
 
@@ -704,7 +706,10 @@ bonobo_control_set_control_frame (Bonobo
 	if (control->priv->control_frame != CORBA_OBJECT_NIL)
 		CORBA_Object_release (control->priv->control_frame, &ev);
 	
-	control->priv->control_frame = CORBA_Object_duplicate (control_frame, &ev);
+	if (control_frame == CORBA_OBJECT_NIL)
+		control->priv->control_frame = CORBA_OBJECT_NIL;
+	else
+		control->priv->control_frame = CORBA_Object_duplicate (control_frame, &ev);
 	
 	CORBA_exception_free (&ev);
 
@@ -717,7 +722,7 @@ bonobo_control_set_control_frame (Bonobo
  * being retrieved.
  *
  * Returns: The Bonobo_ControlFrame CORBA object associated with @control, this is
- * a CORBA_object_duplicated object.  You need to CORBA_free it when you are
+ * a CORBA_Object_duplicated object.  You need to CORBA_Object_release it when you are
  * done with it.
  */
 Bonobo_ControlFrame


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