From 8f1829c10ba3de26fc6f21be4ca74203d74c871f Mon Sep 17 00:00:00 2001 From: Riccardo Bernardini <> Date: Sat, 3 Oct 2015 08:14:44 +0200 Subject: Crash. Fix for Bug #1404934 (Crash when opening files (Glib::ConvertError exception)). Fixed bugs: - https://launchpad.net/bugs/1404934 (bzr r14393) --- src/resource-manager.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/resource-manager.cpp') diff --git a/src/resource-manager.cpp b/src/resource-manager.cpp index fe53eca4f..dbff27827 100644 --- a/src/resource-manager.cpp +++ b/src/resource-manager.cpp @@ -222,11 +222,15 @@ std::map 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()); } } } -- cgit v1.2.3 From 93650897c928bfa9ca9b737cfbff55c25271d5d3 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Tue, 8 Dec 2015 00:34:32 +0100 Subject: cppification : GHashMaps replaced by stl maps. getResouceList now gives a std::set. Should give some performance improvements (quite a few linear lookups are now logarithmic) (bzr r14504.1.6) --- src/resource-manager.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/resource-manager.cpp') diff --git a/src/resource-manager.cpp b/src/resource-manager.cpp index dbff27827..18d7c6ba2 100644 --- a/src/resource-manager.cpp +++ b/src/resource-manager.cpp @@ -179,9 +179,9 @@ std::vector ResourceManagerImpl::findBrokenLinks( SPDocument *doc std::set uniques; if ( doc ) { - GSList const *images = doc->getResourceList("image"); - for (GSList const *it = images; it; it = it->next) { - Inkscape::XML::Node *ir = static_cast(it->data)->getRepr(); + std::set images = doc->getResourceList("image"); + for (std::set::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() ) ) { @@ -305,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(it->data)->getRepr(); + + std::set images = doc->getResourceList("image"); + for (std::set::const_iterator it = images.begin(); it != images.end(); ++it) { + Inkscape::XML::Node *ir = (*it)->getRepr(); gchar const *href = ir->attribute("xlink:href"); if ( href ) { -- cgit v1.2.3