Skip to content

Commit

Permalink
libathemecore: if an object being unref'd is already being disposed, …
Browse files Browse the repository at this point in the history
…just make the unref a noop
  • Loading branch information
kaniini committed Mar 5, 2012
1 parent d0b8c26 commit 03031b3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions libathemecore/object.c
Expand Up @@ -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);
}
}

/*
Expand Down

0 comments on commit 03031b3

Please sign in to comment.