summaryrefslogtreecommitdiffstats
path: root/src/io
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2019-01-15 14:49:08 +0000
committerMarc Jeanmougin <marc@jeanmougin.fr>2019-01-15 14:49:08 +0000
commitd4cc46084652526cf02221c80c9898d1e7d76e4e (patch)
tree41eff4a7b8e85adbf94181f6a71b52a1b50eaec1 /src/io
parentDo not translate appdata and desktop when they are not installed (diff)
parentInitialize unused variable. (diff)
downloadinkscape-d4cc46084652526cf02221c80c9898d1e7d76e4e.tar.gz
inkscape-d4cc46084652526cf02221c80c9898d1e7d76e4e.zip
Merge branch 'master' of gitlab.com:inkscape/inkscape
Diffstat (limited to 'src/io')
-rw-r--r--src/io/file.cpp20
-rw-r--r--src/io/file.h2
2 files changed, 19 insertions, 3 deletions
diff --git a/src/io/file.cpp b/src/io/file.cpp
index 3505f018d..5877e2727 100644
--- a/src/io/file.cpp
+++ b/src/io/file.cpp
@@ -21,6 +21,8 @@
#include "extension/output.h"
#include "extension/input.h"
+#include "object/sp-root.h"
+
// SPDocument*
// ink_file_new(const std::string &Template)
// {
@@ -30,8 +32,9 @@
SPDocument*
-ink_file_open(const Glib::RefPtr<Gio::File>& file)
+ink_file_open(const Glib::RefPtr<Gio::File>& file, bool &cancelled)
{
+ cancelled = false;
SPDocument *doc = nullptr;
@@ -43,20 +46,33 @@ ink_file_open(const Glib::RefPtr<Gio::File>& file)
doc = nullptr;
} catch (Inkscape::Extension::Input::open_failed &e) {
doc = nullptr;
+ } catch (Inkscape::Extension::Input::open_cancelled &e) {
+ cancelled = true;
+ doc = nullptr;
}
// Try to open explicitly as SVG.
- if (doc == nullptr) {
+ if (doc == nullptr && !cancelled) {
try {
doc = Inkscape::Extension::open(Inkscape::Extension::db.get(SP_MODULE_KEY_INPUT_SVG), path.c_str());
} catch (Inkscape::Extension::Input::no_extension_found &e) {
doc = nullptr;
} catch (Inkscape::Extension::Input::open_failed &e) {
doc = nullptr;
+ } catch (Inkscape::Extension::Input::open_cancelled &e) {
+ cancelled = true;
+ doc = nullptr;
}
}
+
if (doc == nullptr) {
std::cerr << "ink_file_open: '" << path << "' cannot be opened!" << std::endl;
+ } else {
+
+ // This is the only place original values should be set.
+ SPRoot *root = doc->getRoot();
+ root->original.inkscape = root->version.inkscape;
+ root->original.svg = root->version.svg;
}
return doc;
diff --git a/src/io/file.h b/src/io/file.h
index e1b91adcd..b911563b7 100644
--- a/src/io/file.h
+++ b/src/io/file.h
@@ -14,7 +14,7 @@
class SPDocument;
//SPDocument* ink_file_new(const std::string &template = nullptr);
-SPDocument* ink_file_open(const Glib::RefPtr<Gio::File>& file = Glib::RefPtr<Gio::File>());
+SPDocument* ink_file_open(const Glib::RefPtr<Gio::File>& file, bool &cancelled);
// To do:
// ink_file_save()