From d8d60c60ebeeefb068d9b68bf7d96f1f1f88518a Mon Sep 17 00:00:00 2001 From: Adib Taraben Date: Sat, 1 Aug 2009 23:31:02 +0000 Subject: FIX 309856 353847: correctly advertise exception leads to error message dialogue (bzr r8380) --- src/extension/implementation/script.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/extension/implementation/script.cpp') 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())) { -- cgit v1.2.3 From 4cd79453c07adefb912a4dbd0afb2e7c2722bd90 Mon Sep 17 00:00:00 2001 From: johnce Date: Wed, 5 Aug 2009 06:38:07 +0000 Subject: SPDocument->Document (bzr r8408) --- src/extension/implementation/script.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/extension/implementation/script.cpp') diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index e6ce40bc0..d207c1a19 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -545,7 +545,7 @@ Script::prefs_output(Inkscape::Extension::Output *module) the incoming filename (so that it's not the temporary filename). That document is then returned from this function. */ -SPDocument * +Document * Script::open(Inkscape::Extension::Input *module, const gchar *filenameArg) { @@ -567,7 +567,7 @@ Script::open(Inkscape::Extension::Input *module, int data_read = execute(command, params, lfilename, fileout); fileout.toFile(tempfilename_out); - SPDocument * mydoc = NULL; + Document * mydoc = NULL; if (data_read > 10) { if (helper_extension.size()==0) { mydoc = Inkscape::Extension::open( @@ -623,7 +623,7 @@ Script::open(Inkscape::Extension::Input *module, */ void Script::save(Inkscape::Extension::Output *module, - SPDocument *doc, + Document *doc, const gchar *filenameArg) { std::list params; @@ -757,7 +757,7 @@ Script::effect(Inkscape::Extension::Effect *module, pump_events(); - SPDocument * mydoc = NULL; + Document * mydoc = NULL; if (data_read > 10) { mydoc = Inkscape::Extension::open( Inkscape::Extension::db.get(SP_MODULE_KEY_INPUT_SVG), -- cgit v1.2.3 From 51c2905fd3e99955db2d823b79abb763d8097028 Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Thu, 6 Aug 2009 14:17:17 +0000 Subject: Revert recent refactoring changes by johnce because they break the build, which cannot be fixed easily. (bzr r8422) --- src/extension/implementation/script.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/extension/implementation/script.cpp') diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index d207c1a19..e6ce40bc0 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -545,7 +545,7 @@ Script::prefs_output(Inkscape::Extension::Output *module) the incoming filename (so that it's not the temporary filename). That document is then returned from this function. */ -Document * +SPDocument * Script::open(Inkscape::Extension::Input *module, const gchar *filenameArg) { @@ -567,7 +567,7 @@ Script::open(Inkscape::Extension::Input *module, int data_read = execute(command, params, lfilename, fileout); fileout.toFile(tempfilename_out); - Document * mydoc = NULL; + SPDocument * mydoc = NULL; if (data_read > 10) { if (helper_extension.size()==0) { mydoc = Inkscape::Extension::open( @@ -623,7 +623,7 @@ Script::open(Inkscape::Extension::Input *module, */ void Script::save(Inkscape::Extension::Output *module, - Document *doc, + SPDocument *doc, const gchar *filenameArg) { std::list params; @@ -757,7 +757,7 @@ Script::effect(Inkscape::Extension::Effect *module, pump_events(); - Document * mydoc = NULL; + SPDocument * mydoc = NULL; if (data_read > 10) { mydoc = Inkscape::Extension::open( Inkscape::Extension::db.get(SP_MODULE_KEY_INPUT_SVG), -- cgit v1.2.3 From 606ebb35498c3d750bb2906954195baaa0fbcad6 Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Sun, 9 Aug 2009 14:23:52 +0000 Subject: Fix remaining glitches in the behaviour of the Save dialogs (w.r.t. remembering the last file type and folder). As part of the cleanup inkscape:output_extension was removed, too. (bzr r8454) --- src/extension/implementation/script.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/extension/implementation/script.cpp') diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index e6ce40bc0..5f1bef8d1 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -477,7 +477,7 @@ ScriptDocCache::ScriptDocCache (Inkscape::UI::View::View * view) : Inkscape::Extension::save( Inkscape::Extension::db.get(SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE), - view->doc(), _filename.c_str(), false, false, false); + view->doc(), _filename.c_str(), false, false, false, Inkscape::Extension::FILE_SAVE_METHOD_TEMPORARY); return; } @@ -641,11 +641,13 @@ Script::save(Inkscape::Extension::Output *module, if (helper_extension.size() == 0) { Inkscape::Extension::save( Inkscape::Extension::db.get(SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE), - doc, tempfilename_in.c_str(), false, false, false); + doc, tempfilename_in.c_str(), false, false, false, + Inkscape::Extension::FILE_SAVE_METHOD_TEMPORARY); } else { Inkscape::Extension::save( Inkscape::Extension::db.get(helper_extension.c_str()), - doc, tempfilename_in.c_str(), false, false, false); + doc, tempfilename_in.c_str(), false, false, false, + Inkscape::Extension::FILE_SAVE_METHOD_TEMPORARY); } @@ -714,8 +716,6 @@ Script::effect(Inkscape::Extension::Effect *module, SPDesktop *desktop = (SPDesktop *)doc; sp_namedview_document_from_window(desktop); - gchar * orig_output_extension = g_strdup(sp_document_repr_root(desktop->doc())->attribute("inkscape:output_extension")); - std::list params; module->paramListString(params); @@ -779,10 +779,7 @@ Script::effect(Inkscape::Extension::Effect *module, doc->doc()->emitReconstructionFinish(); mydoc->release(); sp_namedview_update_layers_from_document(desktop); - - sp_document_repr_root(desktop->doc())->setAttribute("inkscape:output_extension", orig_output_extension); } - g_free(orig_output_extension); return; } -- cgit v1.2.3