[Workman-devel] [PATCH] Set pointers to NULL in dispose
Daniel P. Berrange
berrange at redhat.com
Wed Mar 6 22:08:36 UTC 2013
On Wed, Mar 06, 2013 at 02:47:26PM -0600, Josh Poimboeuf wrote:
> The dispose() method can be called more than once, so set the object
> pointers to NULL after freeing the corresponding objects.
> ---
> workman/workman-attribute.c | 1 +
> workman/workman-object.c | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/workman/workman-attribute.c b/workman/workman-attribute.c
> index 67faa6d..6f98790 100644
> --- a/workman/workman-attribute.c
> +++ b/workman/workman-attribute.c
> @@ -52,6 +52,7 @@ workman_attribute_dispose(GObject *object)
> WorkmanAttribute *self = WORKMAN_ATTRIBUTE(object);
>
> g_variant_unref(self->priv->value);
> + self->priv->value = NULL;
>
> G_OBJECT_CLASS(workman_attribute_parent_class)->dispose(object);
> }
> diff --git a/workman/workman-object.c b/workman/workman-object.c
> index 78487ed..6b60dfe 100644
> --- a/workman/workman-object.c
> +++ b/workman/workman-object.c
> @@ -136,6 +136,7 @@ workman_object_dispose(GObject *object)
> WorkmanObject *self = WORKMAN_OBJECT(object);
>
> workman_object_attributes_free(self->priv->attributes);
> + self->priv->attributes = NULL;
>
> G_OBJECT_CLASS(workman_object_parent_class)->dispose(object);
> }
ACK, though could we just use finalize instead of dispose ?
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the Workman-devel
mailing list