Re: Refcounting craziness



Michael Meeks <michael ximian com> writes:

> On 24 Jan 2001, Havoc Pennington wrote:
> > Well, the specific horror pointed out was a roundabout way of writing:
> >
> >  while (object->ref_count)
> >    unref (object);
>      
>         Please do point it out again, either way the original module
> pointed at been substantialy re-written. The above seems rather strange.
> 
>         I can believe we were keeping a non-reffed copy and listening on  
> the destroy signal to maintain a copy without creating reference loops, I
> don't recollect anything quite so dumb as:
> 
>         while (use_memory_that_might_have_just_been_freed->ref)
>                 unref (use_memory_that_might_have_just_been_freed->ref);

=================
static void
bonobo_embeddable_destroy (GtkObject *object)
{
	BonoboEmbeddable *embeddable = BONOBO_EMBEDDABLE (object);

	/*
	 * Destroy all our views.
	 */
	while (embeddable->priv->views) {
		BonoboView *view = BONOBO_VIEW (embeddable->priv->views->data);

		bonobo_object_unref (BONOBO_OBJECT (view));
	}
=================

So, for each view, it unrefs it until the refcount goes to zero
and the view is destroyed and removed from embeddable->priv->views
by a ::destroy callback.

Regards,
                                        Owen





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