From 03031b354307b0e362a6264c32ad380bf74d0885 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 4 Mar 2012 21:57:34 -0600 Subject: [PATCH] libathemecore: if an object being unref'd is already being disposed, just make the unref a noop --- libathemecore/object.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libathemecore/object.c b/libathemecore/object.c index 0f19ed4952..25dadc3b06 100644 --- a/libathemecore/object.c +++ b/libathemecore/object.c @@ -151,11 +151,16 @@ void *object_sink_ref(void *obj) void object_unref(void *obj) { return_if_fail(obj != NULL); - return_if_fail(object(obj)->refcount > 0); + return_if_fail(object(obj)->refcount >= -1); - object_sink_ref(obj); - if (object(obj)->refcount == 0) - object_dispose(obj); + if (object(obj)->refcount == -1) + return; + else if (object(obj)->refcount > 0) + { + object_sink_ref(obj); + if (object(obj)->refcount == 0) + object_dispose(obj); + } } /*