summaryrefslogtreecommitdiffstats
path: root/src/uri-references.cpp
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2014-01-22 19:58:15 +0000
committerMartin Owens <doctormo@gmail.com>2014-01-22 19:58:15 +0000
commit9a0c54cb8bc9b0bfc0c6af95f4b156fd717179a8 (patch)
tree18809c1bfa21ea2ab6e319a3308dc2d3010a3bd7 /src/uri-references.cpp
parentImprove use tag logic by recording the loaded documents in a list. (diff)
downloadinkscape-9a0c54cb8bc9b0bfc0c6af95f4b156fd717179a8.tar.gz
inkscape-9a0c54cb8bc9b0bfc0c6af95f4b156fd717179a8.zip
Protect against infinate looping of new included hrefs
(bzr r12970)
Diffstat (limited to 'src/uri-references.cpp')
-rw-r--r--src/uri-references.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/uri-references.cpp b/src/uri-references.cpp
index adf948c7b..30e832c04 100644
--- a/src/uri-references.cpp
+++ b/src/uri-references.cpp
@@ -64,25 +64,32 @@ void URIReference::attach(const URI &uri) throw(BadURIException)
std::string absPath = Glib::build_filename(basePath, std::string( path ) );
path = absPath.c_str();
- // We look at existing children and parents
SPDocument *parent = document;
SPDocument *original = document;
document = NULL;
- while(parent != NULL) {
+ while(parent != NULL && document == NULL) {
+ // Check myself and any parents int he chain
+ if(strcmp(parent->getURI(), path)==0) {
+ document = parent;
+ break;
+ }
+ // Then check children of those.
boost::ptr_list<SPDocument>::iterator iter;
for (iter = parent->child_documents.begin();
iter != parent->child_documents.end(); ++iter) {
- if(strcmp(iter->getURI(), path)==0)
+ if(strcmp(iter->getURI(), path)==0) {
document = &*iter;
+ break;
+ }
}
parent = parent->parent_document;
}
+
// Load a fresh document from the svg source.
if(!document) {
- document = SPDocument::createNewDoc(path, FALSE);
+ document = SPDocument::createNewDoc(path, false, false, original);
if(document) {
- document->parent_document = original;
original->child_documents.push_back(document);
} else {
g_warning("Could not load svg file: %s", path);