diff options
Diffstat (limited to 'src/object/sp-object.cpp')
| -rw-r--r-- | src/object/sp-object.cpp | 40 |
1 files changed, 29 insertions, 11 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++ |
