Permalink
Browse files

libathemecore: if an object being unref'd is already being disposed, …

…just make the unref a noop
  • Loading branch information...
1 parent d0b8c26 commit 03031b354307b0e362a6264c32ad380bf74d0885 @kaniini kaniini committed Mar 5, 2012
Showing with 9 additions and 4 deletions.
  1. +9 −4 libathemecore/object.c
View
@@ -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);
+ }
}
/*

0 comments on commit 03031b3

Please sign in to comment.