=== modified file 'src/document.cpp' --- src/document.cpp 2014-02-20 19:22:58 +0000 +++ src/document.cpp 2014-03-10 21:13:04 +0000 @@ -1546,7 +1546,8 @@ SPGradient *gr = SP_GRADIENT(src); for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) { if (trg && SP_IS_GRADIENT(trg) && src != trg) { - if (gr->isEquivalent(SP_GRADIENT(trg))) { + if (gr->isEquivalent(SP_GRADIENT(trg)) && + gr->isAligned(SP_GRADIENT(trg))) { // Change object references to the existing equivalent gradient change_def_references(src, trg); duplicate = true; === modified file 'src/id-clash.cpp' --- src/id-clash.cpp 2014-02-20 19:22:58 +0000 +++ src/id-clash.cpp 2014-03-10 21:13:37 +0000 @@ -215,9 +215,10 @@ SPObject *cd_obj = current_doc->getObjectById(id); if (cd_obj && SP_IS_GRADIENT(cd_obj)) { - SPGradient *cd_gr = SP_GRADIENT(cd_obj); - if (cd_gr->isEquivalent(SP_GRADIENT(elem))) { - fix_clashing_ids = false; + SPGradient *cd_gr = SP_GRADIENT(cd_obj); + if ( cd_gr->isEquivalent(SP_GRADIENT(elem)) && + cd_gr->isAligned(SP_GRADIENT(elem))) { + fix_clashing_ids = false; } } } === modified file 'src/sp-gradient.cpp' --- src/sp-gradient.cpp 2013-10-21 11:07:45 +0000 +++ src/sp-gradient.cpp 2014-03-10 21:14:04 +0000 @@ -135,6 +135,25 @@ return TRUE; } +/** + * return true if this gradient is "aligned" to that gradient. + * Aligned means that they have exactly the same transform. + * @param that - A gradient to compare this to + */ +gboolean SPGradient::isAligned(SPGradient *that) +{ + bool status = FALSE; + + while(1){ // not really a loop, used to avoid deep nesting or multiple exit points from function + if(this->gradientTransform_set != that->gradientTransform_set) { break; } + if(this->gradientTransform_set && + (this->gradientTransform != that->gradientTransform)) { break; } + status = TRUE; + break; + } + return status; +} + /* * Gradient === modified file 'src/sp-gradient.h' --- src/sp-gradient.h 2013-09-15 00:43:49 +0000 +++ src/sp-gradient.h 2014-03-10 19:06:10 +0000 @@ -147,6 +147,7 @@ int getStopCount() const; gboolean isEquivalent(SPGradient *b); + gboolean isAligned(SPGradient *b); /** Mesh Gradients **************/