summaryrefslogtreecommitdiffstats
path: root/src/object
diff options
context:
space:
mode:
Diffstat (limited to 'src/object')
-rw-r--r--src/object/sp-object.cpp40
-rw-r--r--src/object/sp-object.h1
-rw-r--r--src/object/uri-references.cpp12
3 files changed, 36 insertions, 17 deletions
diff --git a/src/object/sp-object.cpp b/src/object/sp-object.cpp
index e82329d1b..764453ab3 100644
--- a/src/object/sp-object.cpp
+++ b/src/object/sp-object.cpp
@@ -267,8 +267,13 @@ SPObject *sp_object_unref(SPObject *object, SPObject *owner)
void SPObject::hrefObject(SPObject* owner)
{
- hrefcount++;
- _updateTotalHRefCount(1);
+ // if (owner) std::cout << " owner: " << *owner << std::endl;
+
+ // If owner is a clone, do not increase hrefcount, it's already href'ed by original.
+ if (!owner || !owner->cloned) {
+ hrefcount++;
+ _updateTotalHRefCount(1);
+ }
if(owner)
hrefList.push_front(owner);
@@ -278,7 +283,10 @@ void SPObject::unhrefObject(SPObject* owner)
{
g_return_if_fail(hrefcount > 0);
- hrefcount--;
+ if (!owner || !owner->cloned) {
+ hrefcount--;
+ }
+
_updateTotalHRefCount(-1);
if(owner)
@@ -1616,7 +1624,9 @@ void SPObject::recursivePrintTree( unsigned level )
for (unsigned i = 0; i < level; ++i) {
std::cout << " ";
}
- std::cout << (getId()?getId():"No object id") << std::endl;
+ std::cout << (getId()?getId():"No object id")
+ << " clone: " << std::boolalpha << (bool)cloned
+ << " hrefcount: " << hrefcount << std::endl;
for (auto& child: children) {
child.recursivePrintTree(level + 1);
}
@@ -1632,9 +1642,10 @@ void SPObject::objectTrace( std::string text, bool in, unsigned flags ) {
std::cout << text << ":"
<< " entrance: "
<< (id?id:"null")
- << " uflags: " << uflags
- << " mflags: " << mflags
- << " flags: " << flags << std::endl;
+ // << " uflags: " << uflags
+ // << " mflags: " << mflags
+ // << " flags: " << flags
+ << std::endl;
++indent_level;
} else {
--indent_level;
@@ -1642,14 +1653,21 @@ void SPObject::objectTrace( std::string text, bool in, unsigned flags ) {
std::cout << " ";
}
std::cout << text << ":"
- << " exit: "
+ << " exit: "
<< (id?id:"null")
- << " uflags: " << uflags
- << " mflags: " << mflags
- << " flags: " << flags << std::endl;
+ // << " uflags: " << uflags
+ // << " mflags: " << mflags
+ // << " flags: " << flags
+ << std::endl;
}
}
+std::ostream &operator<<(std::ostream &out, const SPObject &o)
+{
+ out << (o.getId()?o.getId():"No ID")
+ << " cloned: " << std::boolalpha << (bool)o.cloned;
+ return out;
+}
/*
Local Variables:
mode:c++
diff --git a/src/object/sp-object.h b/src/object/sp-object.h
index 77e5947ad..35020a36e 100644
--- a/src/object/sp-object.h
+++ b/src/object/sp-object.h
@@ -841,6 +841,7 @@ public:
void objectTrace( std::string, bool in=true, unsigned flags=0 );
};
+std::ostream &operator<<(std::ostream &out, const SPObject &o);
/**
* Compares height of objects in tree.
diff --git a/src/object/uri-references.cpp b/src/object/uri-references.cpp
index 35c1d7e17..b257eecef 100644
--- a/src/object/uri-references.cpp
+++ b/src/object/uri-references.cpp
@@ -47,7 +47,10 @@ URIReference::URIReference(SPDocument *owner_document)
g_assert(_owner_document != nullptr);
}
-URIReference::~URIReference() { detach(); }
+URIReference::~URIReference()
+{
+ detach();
+}
/*
* The main ideas here are:
@@ -106,8 +109,6 @@ bool URIReference::_acceptObject(SPObject *obj) const
return true;
}
-
-
void URIReference::attach(const URI &uri)
{
SPDocument *document = nullptr;
@@ -188,7 +189,6 @@ void URIReference::attach(const URI &uri)
_setObject(document->getObjectById(id));
_connection = document->connectIdChanged(id, sigc::mem_fun(*this, &URIReference::_setObject));
-
g_free(id);
}
@@ -213,12 +213,12 @@ void URIReference::_setObject(SPObject *obj)
_obj = obj;
_release_connection.disconnect();
- if (_obj) {
+ if (_obj && (!_owner || !_owner->cloned)) {
_obj->hrefObject(_owner);
_release_connection = _obj->connectRelease(sigc::mem_fun(*this, &URIReference::_release));
}
_changed_signal.emit(old_obj, _obj);
- if (old_obj) {
+ if (old_obj && (!_owner || !_owner->cloned)) {
/* release the old object _after_ the signal emission */
old_obj->unhrefObject(_owner);
}