summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-04-08 19:01:11 +0000
committerMarkus Engel <markus.engel@tum.de>2013-04-08 19:01:11 +0000
commit9fd15efa4ab3302f3f9d7c7473a5377af314021c (patch)
tree61c838bd878be255d82f70d0dc8b2bb8411550b7 /src
parentAdded exception to SPFactory / basic handling to SPObject. (diff)
downloadinkscape-9fd15efa4ab3302f3f9d7c7473a5377af314021c.tar.gz
inkscape-9fd15efa4ab3302f3f9d7c7473a5377af314021c.zip
Reactivated independent reference counting in the SPObject tree.
(bzr r11608.1.88)
Diffstat (limited to 'src')
-rw-r--r--src/gradient-drag.cpp6
-rw-r--r--src/knotholder.cpp7
-rw-r--r--src/sp-object.cpp9
-rw-r--r--src/sp-object.h1
-rw-r--r--src/sp-switch.cpp6
5 files changed, 23 insertions, 6 deletions
diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp
index a1bc97888..fb58aa508 100644
--- a/src/gradient-drag.cpp
+++ b/src/gradient-drag.cpp
@@ -709,12 +709,14 @@ GrDraggable::GrDraggable(SPItem *item, GrPointType point_type, guint point_i, In
point_i(point_i),
fill_or_stroke(fill_or_stroke)
{
- g_object_ref(G_OBJECT(item));
+ //g_object_ref(G_OBJECT(item));
+ sp_object_ref(item);
}
GrDraggable::~GrDraggable()
{
- g_object_unref (G_OBJECT (this->item));
+ //g_object_unref (G_OBJECT (this->item));
+ sp_object_unref(this->item);
}
diff --git a/src/knotholder.cpp b/src/knotholder.cpp
index 62119698f..32ba9075b 100644
--- a/src/knotholder.cpp
+++ b/src/knotholder.cpp
@@ -63,13 +63,16 @@ KnotHolder::KnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFun
g_print ("Error! Throw an exception, please!\n");
}
- g_object_ref(G_OBJECT(item)); // TODO: is this still needed after C++-ification?
+ //g_object_ref(G_OBJECT(item)); // TODO: is this still needed after C++-ification?
+ sp_object_ref(item);
sizeUpdatedConn = ControlManager::getManager().connectCtrlSizeChanged(sigc::mem_fun(*this, &KnotHolder::updateControlSizes));
}
KnotHolder::~KnotHolder() {
- g_object_unref(G_OBJECT(item));
+ //g_object_unref(G_OBJECT(item));
+ sp_object_unref(item);
+
for (std::list<KnotHolderEntity *>::iterator i = entity.begin(); i != entity.end(); ++i)
{
delete (*i);
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<RefEvent> 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<UnrefEvent> tracker(object);
//g_object_unref(G_OBJECT(object));
+ object->refCount--;
+
+ if (object->refCount < 0) {
+ delete object;
+ }
+
return NULL;
}
diff --git a/src/sp-object.h b/src/sp-object.h
index e57a0d3d7..cb264a16c 100644
--- a/src/sp-object.h
+++ b/src/sp-object.h
@@ -207,6 +207,7 @@ private:
gchar *id; /* Our very own unique id */
Inkscape::XML::Node *repr; /* Our xml representation */
public:
+ int refCount;
/**
* Returns the objects current ID string.
diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp
index ec4d9c1f0..cc50a8fef 100644
--- a/src/sp-switch.cpp
+++ b/src/sp-switch.cpp
@@ -63,8 +63,10 @@ GSList *SPSwitch::_childList(bool add_ref, SPObject::Action action) {
if (NULL == child)
return NULL;
- if (add_ref)
- g_object_ref (G_OBJECT (child));
+ if (add_ref) {
+ //g_object_ref (G_OBJECT (child));
+ sp_object_ref(child);
+ }
return g_slist_prepend (NULL, child);
}