From: theadib Date: Sat, 1 Aug 2009 23:31:02 +0000 (+0000) Subject: FIX 309856 353847: correctly advertise exception leads to error message dialogue X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0886032fe58925a0b7a91e2039afb8f45a79d57c;p=inkscape.git FIX 309856 353847: correctly advertise exception leads to error message dialogue --- diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index eabf147f6..e6ce40bc0 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -63,7 +63,7 @@ namespace Extension { namespace Implementation { /** \brief Make GTK+ events continue to come through a little bit - + This just keeps coming the events through so that we'll make the GUI update and look pretty. */ @@ -604,6 +604,7 @@ Script::open(Inkscape::Extension::Input *module, \param module Extention to be used \param doc Document to be saved \param filename The name to save the final file as + \return false in case of any failure writing the file, otherwise true Well, at some point people need to save - it is really what makes the entire application useful. And, it is possible that someone @@ -634,7 +635,7 @@ Script::save(Inkscape::Extension::Output *module, tempfd_in = Inkscape::IO::file_open_tmp(tempfilename_in, "ink_ext_XXXXXX.svg"); } catch (...) { /// \todo Popup dialog here - return; + throw Inkscape::Extension::Output::save_failed(); } if (helper_extension.size() == 0) { @@ -652,13 +653,17 @@ Script::save(Inkscape::Extension::Output *module, execute(command, params, tempfilename_in, fileout); std::string lfilename = Glib::filename_from_utf8(filenameArg); - fileout.toFile(lfilename); + bool success = fileout.toFile(lfilename); // make sure we don't leak file descriptors from g_file_open_tmp close(tempfd_in); // FIXME: convert to utf8 (from "filename encoding") and unlink_utf8name unlink(tempfilename_in.c_str()); + if(success == false) { + throw Inkscape::Extension::Output::save_failed(); + } + return; } @@ -840,7 +845,7 @@ Script::copy_doc (Inkscape::XML::Node * oldroot, Inkscape::XML::Node * newroot) { using Inkscape::Util::List; - using Inkscape::XML::AttributeRecord; + using Inkscape::XML::AttributeRecord; std::vector attribs; // Make a list of all attributes of the old root node. @@ -1007,7 +1012,7 @@ Script::execute (const std::list &in_command, for (std::list::const_iterator i = in_params.begin(); i != in_params.end(); i++) { //g_message("Script parameter: %s",(*i)g.c_str()); - argv.push_back(*i); + argv.push_back(*i); } if (!(filein.empty())) { diff --git a/src/extension/implementation/script.h b/src/extension/implementation/script.h index 4620375f9..8e25fb351 100644 --- a/src/extension/implementation/script.h +++ b/src/extension/implementation/script.h @@ -135,7 +135,7 @@ private: /** * */ - void checkStderr (const Glib::ustring &filename, + void checkStderr (const Glib::ustring &filename, Gtk::MessageType type, const Glib::ustring &message); @@ -146,7 +146,7 @@ private: Glib::RefPtr _channel; Glib::RefPtr _main_loop; bool _dead; - + public: file_listener () : _dead(false) { }; virtual ~file_listener () { @@ -187,11 +187,15 @@ private: // Note, doing a copy here, on purpose Glib::ustring string (void) { return _string; }; - void toFile (const Glib::ustring &name) { + bool toFile (const Glib::ustring &name) { + try { Glib::RefPtr stdout_file = Glib::IOChannel::create_from_file(name, "w"); stdout_file->set_encoding(); stdout_file->write(_string); - return; + } catch (Glib::FileError &e) { + return false; + } + return true; }; }; diff --git a/src/extension/output.cpp b/src/extension/output.cpp index e1481d000..742e938de 100644 --- a/src/extension/output.cpp +++ b/src/extension/output.cpp @@ -218,7 +218,7 @@ Output::save(SPDocument *doc, gchar const *filename) imp->save(this, doc, filename); } catch (...) { - g_warning("There was an error saving the file."); + throw Inkscape::Extension::Output::save_failed(); } return; diff --git a/src/extension/system.cpp b/src/extension/system.cpp index a7828d3fc..33ee544a1 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -277,7 +277,19 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension, doc->setModifiedSinceSave(false); } - omod->save(doc, fileName); + try { + omod->save(doc, fileName); + } + catch(...) { + // free used ressources + if ( !official) { + g_free(saved_output_extension); + g_free(saved_dataloss); + } + g_free(fileName); + + throw Inkscape::Extension::Output::save_failed(); + } // If it is an unofficial save, set the modified attributes back to what they were. if ( !official) {