small patch to bonobo-object.c to get rid of copy/paste code
- From: Darin Adler <darin eazel com>
- To: Gnome Components <gnome-components-list gnome org>
- Subject: small patch to bonobo-object.c to get rid of copy/paste code
- Date: Tue, 28 Mar 2000 18:21:29 -0800
The main change here is to make bonobo_object_unref use
bonobo_object_destroy. A minor tweak I did at the same time is that
BONOBO_IS_OBJECT, like all the GtkObject type check macros, includes a check
for NULL, so I got rid of a lot of redundant separate checks for NULL.
I'll check this in after a day or two if I don't hear from anyone.
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-object.c,v
retrieving revision 1.55
diff -u -r1.55 bonobo-object.c
--- bonobo/bonobo-object.c 2000/02/16 10:27:55 1.55
+++ bonobo/bonobo-object.c 2000/03/29 02:16:18
@@ -73,7 +73,6 @@
PortableServer_Servant
bonobo_object_get_servant (BonoboObject *object)
{
- g_return_val_if_fail (object != NULL, NULL);
g_return_val_if_fail (BONOBO_IS_OBJECT (object), NULL);
return object->servant;
@@ -94,9 +93,8 @@
void
bonobo_object_bind_to_servant (BonoboObject *object, void *servant)
{
- g_return_if_fail (object != NULL);
- g_return_if_fail (servant != NULL);
g_return_if_fail (BONOBO_IS_OBJECT (object));
+ g_return_if_fail (servant != NULL);
object->servant = servant;
((BonoboObjectServant *)servant)->bonobo_object = object;
@@ -111,7 +109,6 @@
void
bonobo_object_ref (BonoboObject *object)
{
- g_return_if_fail (object != NULL);
g_return_if_fail (BONOBO_IS_OBJECT (object));
g_return_if_fail (object->priv->ao->ref_count > 0);
@@ -127,25 +124,13 @@
void
bonobo_object_unref (BonoboObject *object)
{
- g_return_if_fail (object != NULL);
g_return_if_fail (BONOBO_IS_OBJECT (object));
g_return_if_fail (object->priv->ao->ref_count > 0);
-
- object->priv->ao->ref_count--;
-
- if (object->priv->ao->ref_count == 0){
- GnomeAggregateObject *ao = object->priv->ao;
- GList *l;
-
- for (l = ao->objs; l; l = l->next){
- BonoboObject *o = l->data;
- gtk_signal_disconnect (GTK_OBJECT (o), o->priv->destroy_id);
- gtk_object_destroy (GTK_OBJECT (o));
- }
-
- g_list_free (ao->objs);
- g_free (ao);
+ if (object->priv->ao->ref_count == 1) {
+ bonobo_object_destroy (object);
+ } else {
+ object->priv->ao->ref_count--;
}
}
@@ -163,7 +148,6 @@
GnomeAggregateObject *ao;
GList *l;
- g_return_if_fail (object != NULL);
g_return_if_fail (BONOBO_IS_OBJECT (object));
g_return_if_fail (object->priv->ao->ref_count > 0);
@@ -248,7 +232,6 @@
GtkType type;
GList *l;
- g_return_val_if_fail (object != NULL, NULL);
g_return_val_if_fail (BONOBO_IS_OBJECT (object), NULL);
retval = NULL;
@@ -469,7 +452,6 @@
CORBA_Environment ev;
CORBA_Object o;
- g_return_val_if_fail (object != NULL, CORBA_OBJECT_NIL);
g_return_val_if_fail (BONOBO_IS_OBJECT (object), CORBA_OBJECT_NIL);
g_return_val_if_fail (servant != NULL, CORBA_OBJECT_NIL);
@@ -506,7 +488,6 @@
BonoboObject *
bonobo_object_construct (BonoboObject *object, CORBA_Object corba_object)
{
- g_return_val_if_fail (object != NULL, NULL);
g_return_val_if_fail (BONOBO_IS_OBJECT (object), NULL);
g_return_val_if_fail (corba_object != CORBA_OBJECT_NIL, NULL);
@@ -589,7 +570,6 @@
CORBA_Object
bonobo_object_corba_objref (BonoboObject *object)
{
- g_return_val_if_fail (object != NULL, CORBA_OBJECT_NIL);
g_return_val_if_fail (BONOBO_IS_OBJECT (object), NULL);
return object->corba_objref;
@@ -610,9 +590,8 @@
void
bonobo_object_check_env (BonoboObject *object, CORBA_Object obj,
CORBA_Environment *ev)
{
- g_return_if_fail (object != NULL);
- g_return_if_fail (ev != NULL);
g_return_if_fail (BONOBO_IS_OBJECT (object));
+ g_return_if_fail (ev != NULL);
if (ev->_major == CORBA_NO_EXCEPTION)
return;
===================================================================
-- Darin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]