summaryrefslogtreecommitdiffstats
path: root/src/file.cpp
diff options
context:
space:
mode:
authorEduard Braun <eduard.braun2@gmx.de>2018-01-24 21:13:28 +0000
committerEduard Braun <eduard.braun2@gmx.de>2018-01-24 23:22:44 +0000
commit03ccbe208e2da5f2d2fb621ad5f9c59b3d052f28 (patch)
tree2a57e54de1b1348657e227f296c6a07ce6191d84 /src/file.cpp
parentmove install command to logical place (diff)
downloadinkscape-03ccbe208e2da5f2d2fb621ad5f9c59b3d052f28.tar.gz
inkscape-03ccbe208e2da5f2d2fb621ad5f9c59b3d052f28.zip
Always show an error dialog on failed saves
As a result of 2b8d9986140cc36ea6c0a3c3b88571983490e0ef the actual exceptions are now catched (instead of the generic Inkscape::Extension::Output::save_failed) but were not handled yet. Implement this handling for generic exceptions and output any potentially helpful information on what went wrong.
Diffstat (limited to 'src/file.cpp')
-rw-r--r--src/file.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/file.cpp b/src/file.cpp
index 9cf0448e1..e0134e839 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -667,8 +667,25 @@ file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri,
return false;
} catch (Inkscape::Extension::Output::no_overwrite &e) {
return sp_file_save_dialog(parentWindow, doc, save_method);
+ } catch (std::exception &e) {
+ gchar *safeUri = Inkscape::IO::sanitizeString(uri.c_str());
+ gchar *text = g_strdup_printf(_("File %s could not be saved.\n\n"
+ "The following additional information was returned by the output extension:\n"
+ "'%s'"), safeUri, e.what());
+ SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Document not saved."));
+ sp_ui_error_dialog(text);
+ g_free(text);
+ g_free(safeUri);
+ doc->getReprRoot()->setAttribute("inkscape:version", sp_version_to_string( save ));
+ return false;
} catch (...) {
+ g_critical("Extension '%s' threw an unspecified exception.", key->get_id());
+ gchar *safeUri = Inkscape::IO::sanitizeString(uri.c_str());
+ gchar *text = g_strdup_printf(_("File %s could not be saved."), safeUri);
SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Document not saved."));
+ sp_ui_error_dialog(text);
+ g_free(text);
+ g_free(safeUri);
doc->getReprRoot()->setAttribute("inkscape:version", sp_version_to_string( save ));
return false;
}