From a8d7f4db568ca421bab7f4d2828fe2d3c17e6072 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 27 Feb 2014 04:54:34 +0100 Subject: Partial fix for LP #1001756 (crash when ungrouping a selection containing both a group and its clone). There are still some problems with undo/redo (incomplete undo transaction somewhere). (bzr r13063) --- src/sp-use.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/sp-use.cpp') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index b2a51b8d9..e394e84c2 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -299,6 +299,23 @@ SPItem const *SPUse::root() const { return const_cast(this)->root(); } +/** + * Get the number of dereferences or calls to get_original() needed to get an object + * which is not an svg:use. Returns -1 if there is no original object. + */ +int SPUse::cloneDepth() const { + unsigned depth = 1; + SPItem *orig = this->child; + + while (orig && SP_IS_USE(orig)) { + ++depth; + orig = SP_USE(orig)->child; + } + + if (!orig) return -1; + return depth; +} + /** * Returns the effective transform that goes from the ultimate original to given SPUse, both ends * included. -- cgit v1.2.3