bonobo-item-handler



Hey,
	I've just committed this patch to tolerate NULL get_object and
enum_objects callbacks.

Cheers,
Mark.

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libbonobo/ChangeLog,v
retrieving revision 1.258
diff -u -p -r1.258 ChangeLog
--- ChangeLog	2001/12/14 14:07:11	1.258
+++ ChangeLog	2001/12/14 19:12:17
@@ -1,5 +1,11 @@
 2001-12-14  Mark McLoughlin  <mark skynet ie>

+	* bonobo/bonobo-item-handler.c: (bonobo_item_handler_finalize),
+	  (bonobo_item_handler_construct), (bonobo_item_handler_new):
+	tolerate NULL get_object and enum_objects callbacks/closures.
+
+2001-12-14  Mark McLoughlin  <mark skynet ie>
+
 	* bonobo/bonobo-event-source.h,
 	  bonobo/bonobo-generic-factory.h,
 	  bonobo/bonobo-item-container.h,
Index: bonobo/bonobo-item-handler.c
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-item-handler.c,v
retrieving revision 1.18
diff -u -p -r1.18 bonobo-item-handler.c
--- bonobo/bonobo-item-handler.c	2001/11/18 11:07:02	1.18
+++ bonobo/bonobo-item-handler.c	2001/12/14 19:12:17
@@ -161,11 +161,13 @@ bonobo_item_handler_finalize (GObject *o
 {
 	BonoboItemHandler *handler = BONOBO_ITEM_HANDLER (object);

-	if (handler->priv)
-	{
-		g_closure_unref (handler->priv->enum_objects);
-		g_closure_unref (handler->priv->get_object);
+	if (handler->priv) {
+		if (handler->priv->enum_objects)
+			g_closure_unref (handler->priv->enum_objects);

+		if (handler->priv->enum_objects)
+			g_closure_unref (handler->priv->get_object);
+
 		g_free (handler->priv);
 		handler->priv = 0;
 	}
@@ -220,11 +222,13 @@ bonobo_item_handler_construct (BonoboIte
 {
 	g_return_val_if_fail (handler != NULL, NULL);
 	g_return_val_if_fail (BONOBO_IS_ITEM_HANDLER (handler), NULL);
-
-	handler->priv->enum_objects = bonobo_closure_store
-		(enum_objects, bonobo_marshal_POINTER__DUMMY_BOXED);
-	handler->priv->get_object   = bonobo_closure_store
-		(get_object, bonobo_marshal_BOXED__STRING_BOOLEAN_DUMMY_BOXED);
+
+	if (enum_objects)
+		handler->priv->enum_objects = bonobo_closure_store
+			(enum_objects, bonobo_marshal_POINTER__DUMMY_BOXED);
+	if (get_object)
+		handler->priv->get_object = bonobo_closure_store
+			(get_object, bonobo_marshal_BOXED__STRING_BOOLEAN_DUMMY_BOXED);

 	return handler;
 }
@@ -242,9 +246,18 @@ bonobo_item_handler_new (BonoboItemHandl
 			 BonoboItemHandlerGetObjectFn   get_object,
 			 gpointer                       user_data)
 {
-	return bonobo_item_handler_new_closure (
-		g_cclosure_new (G_CALLBACK (enum_objects), user_data, NULL),
-		g_cclosure_new (G_CALLBACK (get_object), user_data, NULL));
+	GClosure *enum_objects_closure = NULL;
+	GClosure *get_object_closure = NULL;
+
+	if (enum_objects)
+		enum_objects_closure =
+			g_cclosure_new (G_CALLBACK (enum_objects), user_data, NULL);
+
+	if (get_object)
+		get_object_closure =
+			g_cclosure_new (G_CALLBACK (get_object), user_data, NULL);
+
+	return bonobo_item_handler_new_closure (enum_objects_closure, get_object_closure);
 }

 /**





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