diff options
Diffstat (limited to 'src/uri-references.cpp')
| -rw-r--r-- | src/uri-references.cpp | 17 |
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); |
