summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Smith <john.smith7545@yahoo.com>2012-10-11 03:34:08 +0000
committerJohn Smith <john.smith7545@yahoo.com>2012-10-11 03:34:08 +0000
commit05c9f6824d14012a71528bd204bcdd4e6624db29 (patch)
tree3df43f36edb9c89ba3ffce431c81b0e16e322b4e /src
parentFix for 246153 : Broken style indicator (diff)
downloadinkscape-05c9f6824d14012a71528bd204bcdd4e6624db29.tar.gz
inkscape-05c9f6824d14012a71528bd204bcdd4e6624db29.zip
Fix for 426763 : Cancelling import leads to error message
(bzr r11777)
Diffstat (limited to 'src')
-rw-r--r--src/extension/implementation/implementation.h1
-rw-r--r--src/extension/input.cpp7
-rw-r--r--src/extension/input.h4
-rw-r--r--src/extension/internal/pdfinput/pdf-input.cpp8
-rw-r--r--src/extension/internal/pdfinput/pdf-input.h4
-rw-r--r--src/extension/system.cpp1
-rw-r--r--src/file.cpp8
7 files changed, 29 insertions, 4 deletions
diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h
index b0230b7c4..fb323cd78 100644
--- a/src/extension/implementation/implementation.h
+++ b/src/extension/implementation/implementation.h
@@ -104,6 +104,7 @@ public:
virtual bool check(Inkscape::Extension::Extension * /*module*/) { return true; }
virtual bool cancelProcessing () { return true; }
+ virtual bool wasCancelled () { return false; }
virtual void commitDocument () {}
// ----- Input functions -----
diff --git a/src/extension/input.cpp b/src/extension/input.cpp
index 1662ef073..5cef38009 100644
--- a/src/extension/input.cpp
+++ b/src/extension/input.cpp
@@ -152,6 +152,10 @@ Input::open (const gchar *uri)
SPDocument *const doc = imp->open(this, uri);
+ if (imp->wasCancelled()) {
+ throw Input::open_cancelled();
+ }
+
return doc;
}
@@ -227,8 +231,7 @@ Input::prefs (const gchar *uri)
delete dialog;
- if (response == Gtk::RESPONSE_OK) return true;
- return false;
+ return (response == Gtk::RESPONSE_OK);
}
} } /* namespace Inkscape, Extension */
diff --git a/src/extension/input.h b/src/extension/input.h
index 8b198495e..b01ffeb86 100644
--- a/src/extension/input.h
+++ b/src/extension/input.h
@@ -39,6 +39,10 @@ public:
virtual ~no_extension_found() throw() {}
const char *what() const throw() { return "No suitable input extension found"; }
};
+ struct open_cancelled : public std::exception {
+ virtual ~open_cancelled() throw() {}
+ const char *what() const throw() { return "Open was cancelled"; }
+ };
Input (Inkscape::XML::Node * in_repr,
Implementation::Implementation * in_imp);
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index 6b6107444..d2d594017 100644
--- a/src/extension/internal/pdfinput/pdf-input.cpp
+++ b/src/extension/internal/pdfinput/pdf-input.cpp
@@ -588,12 +588,19 @@ void PdfImportDialog::_setPreviewPage(int page) {
////////////////////////////////////////////////////////////////////////////////
+bool
+PdfInput::wasCancelled () {
+ return _cancelled;
+}
+
/**
* Parses the selected page of the given PDF document using PdfParser.
*/
SPDocument *
PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
+ _cancelled = false;
+
// Initialize the globalParams variable for poppler
if (!globalParams) {
globalParams = new GlobalParams();
@@ -648,6 +655,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
if (inkscape_use_gui()) {
dlg = new PdfImportDialog(pdf_doc, uri);
if (!dlg->showDialog()) {
+ _cancelled = true;
delete dlg;
delete pdf_doc;
return NULL;
diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h
index 75fcfa69a..e9da5b27c 100644
--- a/src/extension/internal/pdfinput/pdf-input.h
+++ b/src/extension/internal/pdfinput/pdf-input.h
@@ -135,7 +135,9 @@ public:
SPDocument *open( Inkscape::Extension::Input *mod,
const gchar *uri );
static void init( void );
-
+ virtual bool wasCancelled();
+private:
+ bool _cancelled;
};
} // namespace Implementation
diff --git a/src/extension/system.cpp b/src/extension/system.cpp
index fc20095c5..7fb6e1591 100644
--- a/src/extension/system.cpp
+++ b/src/extension/system.cpp
@@ -144,6 +144,7 @@ SPDocument *open(Extension *key, gchar const *filename)
}
SPDocument *doc = imod->open(filename);
+
if (!doc) {
throw Input::open_failed();
}
diff --git a/src/file.cpp b/src/file.cpp
index 778306d5d..a03c459da 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -235,12 +235,16 @@ bool sp_file_open(const Glib::ustring &uri,
}
SPDocument *doc = NULL;
+ bool cancelled = false;
try {
doc = Inkscape::Extension::open(key, uri.c_str());
} catch (Inkscape::Extension::Input::no_extension_found &e) {
doc = NULL;
} catch (Inkscape::Extension::Input::open_failed &e) {
doc = NULL;
+ } catch (Inkscape::Extension::Input::open_cancelled &e) {
+ doc = NULL;
+ cancelled = true;
}
if (desktop) {
@@ -287,7 +291,7 @@ bool sp_file_open(const Glib::ustring &uri,
}
return TRUE;
- } else {
+ } else if (!cancelled) {
gchar *safeUri = Inkscape::IO::sanitizeString(uri.c_str());
gchar *text = g_strdup_printf(_("Failed to load the requested file %s"), safeUri);
sp_ui_error_dialog(text);
@@ -295,6 +299,8 @@ bool sp_file_open(const Glib::ustring &uri,
g_free(safeUri);
return FALSE;
}
+
+ return FALSE;
}
/**