From 03ccbe208e2da5f2d2fb621ad5f9c59b3d052f28 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Wed, 24 Jan 2018 22:13:28 +0100 Subject: 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. --- src/file.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/file.cpp') 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; } -- cgit v1.2.3