diff options
| author | Raphael Rosch <launchpad@insaner.com> | 2014-02-20 19:22:58 +0000 |
|---|---|---|
| committer | insaner <launchpad@insaner.com> | 2014-02-20 19:22:58 +0000 |
| commit | 8a6810210b3b1ce2cb82055063eee635174be637 (patch) | |
| tree | cd4aadb12ed5f3334ba3b460412964a6e99b9a6a /src/id-clash.cpp | |
| parent | Reverting r13045. (diff) | |
| download | inkscape-8a6810210b3b1ce2cb82055063eee635174be637.tar.gz inkscape-8a6810210b3b1ce2cb82055063eee635174be637.zip | |
crash on cut n paste, or alt+scroll..
Fixed bugs:
- https://launchpad.net/bugs/1171109
(bzr r13047)
Diffstat (limited to 'src/id-clash.cpp')
| -rw-r--r-- | src/id-clash.cpp | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/src/id-clash.cpp b/src/id-clash.cpp index c8eacfe02..76b8e6ff8 100644 --- a/src/id-clash.cpp +++ b/src/id-clash.cpp @@ -203,27 +203,44 @@ change_clashing_ids(SPDocument *imported_doc, SPDocument *current_doc, id_changelist_type *id_changes) { const gchar *id = elem->getId(); + bool fix_clashing_ids = true; if (id && current_doc->getObjectById(id)) { // Choose a new ID. // To try to preserve any meaningfulness that the original ID // may have had, the new ID is the old ID followed by a hyphen // and one or more digits. - std::string old_id(id); - std::string new_id(old_id + '-'); - for (;;) { - new_id += "0123456789"[std::rand() % 10]; - const char *str = new_id.c_str(); - if (current_doc->getObjectById(str) == NULL && - imported_doc->getObjectById(str) == NULL) break; + + if (SP_IS_GRADIENT(elem)) { + 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; + } + } } - // Change to the new ID - elem->getRepr()->setAttribute("id", new_id.c_str()); - // Make a note of this change, if we need to fix up refs to it - if (refmap->find(old_id) != refmap->end()) + + if (fix_clashing_ids) { + std::string old_id(id); + std::string new_id(old_id + '-'); + for (;;) { + new_id += "0123456789"[std::rand() % 10]; + const char *str = new_id.c_str(); + if (current_doc->getObjectById(str) == NULL && + imported_doc->getObjectById(str) == NULL) break; + } + // Change to the new ID + + elem->getRepr()->setAttribute("id", new_id.c_str()); + // Make a note of this change, if we need to fix up refs to it + if (refmap->find(old_id) != refmap->end()) id_changes->push_back(id_changeitem_type(elem, old_id)); + } } + // recurse for (SPObject *child = elem->firstChild(); child; child = child->getNext() ) { |
