summaryrefslogtreecommitdiffstats
path: root/src/resource-manager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/resource-manager.cpp')
-rw-r--r--src/resource-manager.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/resource-manager.cpp b/src/resource-manager.cpp
index fe53eca4f..18d7c6ba2 100644
--- a/src/resource-manager.cpp
+++ b/src/resource-manager.cpp
@@ -179,9 +179,9 @@ std::vector<Glib::ustring> ResourceManagerImpl::findBrokenLinks( SPDocument *doc
std::set<Glib::ustring> uniques;
if ( doc ) {
- GSList const *images = doc->getResourceList("image");
- for (GSList const *it = images; it; it = it->next) {
- Inkscape::XML::Node *ir = static_cast<SPObject *>(it->data)->getRepr();
+ std::set<SPObject *> images = doc->getResourceList("image");
+ for (std::set<SPObject *>::const_iterator it = images.begin(); it != images.end(); ++it) {
+ Inkscape::XML::Node *ir = (*it)->getRepr();
gchar const *href = ir->attribute("xlink:href");
if ( href && ( uniques.find(href) == uniques.end() ) ) {
@@ -222,11 +222,15 @@ std::map<Glib::ustring, Glib::ustring> ResourceManagerImpl::locateLinks(Glib::us
Glib::ustring uri = (*it)->get_uri();
std::string scheme = Glib::uri_parse_scheme(uri);
if ( scheme == "file" ) {
- std::string path = Glib::filename_from_uri(uri);
- path = Glib::path_get_dirname(path);
- if ( std::find(priorLocations.begin(), priorLocations.end(), path) == priorLocations.end() ) {
- // TODO debug g_message(" ==>[%s]", path.c_str());
- priorLocations.push_back(path);
+ try {
+ std::string path = Glib::filename_from_uri(uri);
+ path = Glib::path_get_dirname(path);
+ if ( std::find(priorLocations.begin(), priorLocations.end(), path) == priorLocations.end() ) {
+ // TODO debug g_message(" ==>[%s]", path.c_str());
+ priorLocations.push_back(path);
+ }
+ } catch (Glib::ConvertError e) {
+ g_warning("Bad URL ignored [%s]", uri.c_str());
}
}
}
@@ -301,10 +305,10 @@ bool ResourceManagerImpl::fixupBrokenLinks(SPDocument *doc)
bool savedUndoState = DocumentUndo::getUndoSensitive(doc);
DocumentUndo::setUndoSensitive(doc, true);
-
- GSList const *images = doc->getResourceList("image");
- for (GSList const *it = images; it; it = it->next) {
- Inkscape::XML::Node *ir = static_cast<SPObject *>(it->data)->getRepr();
+
+ std::set<SPObject *> images = doc->getResourceList("image");
+ for (std::set<SPObject *>::const_iterator it = images.begin(); it != images.end(); ++it) {
+ Inkscape::XML::Node *ir = (*it)->getRepr();
gchar const *href = ir->attribute("xlink:href");
if ( href ) {