From 9fd15efa4ab3302f3f9d7c7473a5377af314021c Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 8 Apr 2013 21:01:11 +0200 Subject: Reactivated independent reference counting in the SPObject tree. (bzr r11608.1.88) --- src/sp-object.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/sp-object.cpp') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index ff5426282..c2979b609 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -109,6 +109,8 @@ static gchar *sp_object_get_unique_id(SPObject *object, SPObject::SPObject() { debug("id=%x, typename=%s",this, g_type_name_from_instance((GTypeInstance*)object)); + this->refCount = 1; + this->repr = NULL; this->mflags = 0; this->id = NULL; @@ -258,6 +260,7 @@ SPObject *sp_object_ref(SPObject *object, SPObject *owner) Inkscape::Debug::EventTracker tracker(object); //g_object_ref(G_OBJECT(object)); + object->refCount++; return object; } @@ -269,6 +272,12 @@ SPObject *sp_object_unref(SPObject *object, SPObject *owner) Inkscape::Debug::EventTracker tracker(object); //g_object_unref(G_OBJECT(object)); + object->refCount--; + + if (object->refCount < 0) { + delete object; + } + return NULL; } -- cgit v1.2.3