From 2e482a17057e5c71d353e24925f17db485bee129 Mon Sep 17 00:00:00 2001 From: Ivan Mahonin Date: Jun 18 2016 11:35:38 +0000 Subject: Fix bugs related to filenaming --- diff --git a/synfig-core/src/modules/lyr_std/import.cpp b/synfig-core/src/modules/lyr_std/import.cpp index 23d50db..843d4e3 100644 --- a/synfig-core/src/modules/lyr_std/import.cpp +++ b/synfig-core/src/modules/lyr_std/import.cpp @@ -116,22 +116,8 @@ Import::set_param(const String & param, const ValueBase &value) // TODO: find source of this sreening of unicode characters // Get rid of any %20 crap - { - String::size_type n; - while((n=fixed_filename.find("%20"))!=String::npos) - fixed_filename.replace(n,3," "); - } - -#ifndef _WIN32 - if(is_absolute_path(fixed_filename)) - { - string curpath(cleanup_path(absolute_path(get_canvas()->get_file_path()))); - while(basename(curpath)==".")curpath=dirname(curpath); - - fixed_filename=relative_path(curpath,fixed_filename); - info("basename(curpath)=%s, Path adjusted to %s",basename(curpath).c_str(),fixed_filename.c_str()); - } -#endif + for(String::size_type n; (n = fixed_filename.find("%20")) != String::npos;) + fixed_filename.replace(n,3," "); String full_filename = CanvasFileNaming::make_full_filename(get_canvas()->get_file_name(), fixed_filename); if (full_filename.empty()) @@ -149,7 +135,6 @@ Import::set_param(const String & param, const ValueBase &value) // If we are already loaded, don't reload if(this->independent_filename==independent_filename && importer) { - warning(strprintf(_("Filename seems to already be set to \"%s\" (%s)"), filename.c_str(), param_filename.get(String()).c_str())); param_filename.set(filename); return true; } @@ -170,7 +155,7 @@ Import::set_param(const String & param, const ValueBase &value) surface.clear(); param_filename.set(filename); rendering_surface.reset(); - return false; + return true; } } diff --git a/synfig-core/src/synfig/canvas.cpp b/synfig-core/src/synfig/canvas.cpp index e78cbf9..f4d999b 100644 --- a/synfig-core/src/synfig/canvas.cpp +++ b/synfig-core/src/synfig/canvas.cpp @@ -879,16 +879,12 @@ Canvas::clone(const GUID& deriv_guid, bool for_export)const if(is_inline() && !for_export) { canvas->is_inline_=true; - // \todo this was setting parent_=0 - is there a reason for that? + // \todo this was setting parent=0 - is there a reason for that? // this was causing bug 1838132, where cloning an inline canvas that contains an imported image fails // it was failing to ascertain the absolute pathname of the imported image, since it needs the pathname // of the canvas to get that, which is stored in the parent canvas -// printf("%s:%d clone: setting parent_ of %lx to %lx\n", __FILE__, __LINE__, uintptr_t(canvas.get()), uintptr_t(parent().get())); - canvas->parent_=parent(); -// show_canvas_ancestry(__FILE__, __LINE__, "clone(): old"); -// canvas->show_canvas_ancestry(__FILE__, __LINE__, "clone(): new"); canvas->rend_desc() = rend_desc(); - //canvas->set_inline(parent()); + canvas->set_parent(parent()); } canvas->set_guid(get_guid()^deriv_guid); @@ -937,20 +933,14 @@ Canvas::set_inline(LooseHandle parent) id_=_("in line"); is_inline_=true; -// printf("%s:%d set_inline: setting parent_ of %lx to %lx\n", __FILE__, __LINE__, uintptr_t(this), uintptr_t(parent.get())); - parent_=parent; -// show_canvas_ancestry(__FILE__, __LINE__, "set_inline()"); // Have the parent inherit all of the group stuff - std::map > >::const_iterator iter; - for(iter=group_db_.begin();iter!=group_db_.end();++iter) - { parent->group_db_[iter->first].insert(iter->second.begin(),iter->second.end()); - } - rend_desc()=parent->rend_desc(); + + set_parent(parent); } Canvas::Handle @@ -970,17 +960,13 @@ Canvas::new_child_canvas() { if(is_inline() && parent_) return parent_->new_child_canvas(); -// runtime_error("You cannot create a child Canvas in an inline Canvas"); // Create a new canvas children().push_back(create()); Canvas::Handle canvas(children().back()); -// printf("%s:%d new_child_canvas: setting parent_ of %lx to %lx\n", __FILE__, __LINE__, uintptr_t(canvas.get()), uintptr_t(this)); - canvas->parent_=this; -// canvas->show_canvas_ancestry(__FILE__, __LINE__, "new_child_canvas"); - canvas->rend_desc()=rend_desc(); + canvas->set_parent(this); return canvas; } @@ -990,17 +976,14 @@ Canvas::new_child_canvas(const String &id) { if(is_inline() && parent_) return parent_->new_child_canvas(id); -// runtime_error("You cannot create a child Canvas in an inline Canvas"); // Create a new canvas children().push_back(create()); Canvas::Handle canvas(children().back()); canvas->set_id(id); -// printf("%s:%d new_child_canvas: setting parent_ of %lx to %lx\n", __FILE__, __LINE__, uintptr_t(canvas.get()), uintptr_t(this)); - canvas->parent_=this; -// canvas->show_canvas_ancestry(__FILE__, __LINE__, "new_child_canvas"); canvas->rend_desc()=rend_desc(); + canvas->set_parent(this); return canvas; } @@ -1029,9 +1012,7 @@ Canvas::add_child_canvas(Canvas::Handle child_canvas, const synfig::String& id) child_canvas->is_inline_=false; child_canvas->id_=id; children().push_back(child_canvas); -// printf("%s:%d add_child_canvas: setting parent_ of %lx to %lx\n", __FILE__, __LINE__, uintptr_t(child_canvas.get()), uintptr_t(this)); - child_canvas->parent_=this; -// child_canvas->show_canvas_ancestry(__FILE__, __LINE__, "add_child_canvas"); + child_canvas->set_parent(this); } return child_canvas; @@ -1050,10 +1031,25 @@ Canvas::remove_child_canvas(Canvas::Handle child_canvas) throw Exception::IDNotFound(child_canvas->get_id()); children().remove(child_canvas); + child_canvas->set_parent(0); +} + +void +Canvas::set_parent(const Canvas::LooseHandle &parent) +{ + parent_ = parent; + on_parent_set(); +} -// printf("%s:%d remove_child_canvas: setting parent_ of %lx to 0\n", __FILE__, __LINE__, uintptr_t(child_canvas.get())); - child_canvas->parent_=0; -// child_canvas->show_canvas_ancestry(__FILE__, __LINE__, "remove_child_canvas"); +void +Canvas::on_parent_set() +{ + // parent canvas is important field, + // so assume that canvas replaced for layers + for(std::list::iterator i = children().begin(); i != children().end(); ++i) + (*i)->on_parent_set(); + for(iterator i = begin(); *i; ++i) + (*i)->on_canvas_set(); } void diff --git a/synfig-core/src/synfig/canvas.h b/synfig-core/src/synfig/canvas.h index 4715843..a0659ea 100644 --- a/synfig-core/src/synfig/canvas.h +++ b/synfig-core/src/synfig/canvas.h @@ -539,9 +539,6 @@ public: */ ConstHandle find_canvas(const String &id, String &warnings)const; - //! Sets the file path for the Canvas - //void set_file_path(const String &); - //! Returns the file path from the file name String get_file_path()const; @@ -658,6 +655,8 @@ public: #endif // _DEBUG private: + //! Sets parent and raises on_parent_set event + void set_parent(const Canvas::LooseHandle &parent); //! Adds a \layer to a group given by its \group string to the group //! database void add_group_pair(String group, etl::handle layer); @@ -672,6 +671,8 @@ private: void disconnect_connections(etl::loose_handle layer); protected: + //! Parent changed + virtual void on_parent_set(); //! Sets the Canvas to dirty and calls Node::on_changed() virtual void on_changed(); //! Collects the times (TimePoints) of the Layers of the Canvas and diff --git a/synfig-core/src/synfig/canvasfilenaming.cpp b/synfig-core/src/synfig/canvasfilenaming.cpp index a3694b6..30cb3a3 100644 --- a/synfig-core/src/synfig/canvasfilenaming.cpp +++ b/synfig-core/src/synfig/canvasfilenaming.cpp @@ -84,6 +84,7 @@ CanvasFileNaming::is_container_extension(const String &ext) String CanvasFileNaming::make_short_filename(const String &canvas_filename, const String &filename) { + if (filename.empty()) return String(); String clean_filename = etl::cleanup_path(filename); if (etl::basename(clean_filename).empty()) clean_filename = etl::dirname(clean_filename); @@ -97,13 +98,14 @@ CanvasFileNaming::make_short_filename(const String &canvas_filename, const Strin ? container_prefix + etl::basename(clean_filename.substr(container_prefix.size())) : String(); - if (canvas_filename.empty()) + if (!etl::is_absolute_path(canvas_filename)) return clean_filename; String canvas_absolute_filename = etl::absolute_path(canvas_filename); String canvas_path = etl::dirname(canvas_absolute_filename); String canvas_basename = etl::basename(canvas_absolute_filename); - String relative_filename = etl::relative_path(canvas_path, clean_filename); + String absolute_filename = etl::absolute_path(canvas_path, clean_filename); + String relative_filename = etl::relative_path(canvas_path, absolute_filename); // convert "mycanvas.sfg#images/filename.png" to "#filename.png" String prefix = canvas_basename + container_prefix; @@ -131,6 +133,7 @@ String CanvasFileNaming::make_full_filename(const String &canvas_filename, const String &filename) { String short_filename = make_short_filename(canvas_filename, filename); + if (short_filename.empty()) return String(); if (etl::basename(short_filename).empty()) return String(); if (short_filename.substr(0, container_prefix.size()) == container_prefix) @@ -144,7 +147,7 @@ CanvasFileNaming::make_full_filename(const String &canvas_filename, const String : String(); } - if (canvas_filename.empty()) + if (!etl::is_absolute_path(canvas_filename)) return short_filename; String canvas_absolute_filename = etl::absolute_path(canvas_filename); @@ -158,12 +161,13 @@ String CanvasFileNaming::make_canvas_independent_filename(const String &canvas_filename, const String &filename) { String full_filename = make_full_filename(canvas_filename, filename); + if (full_filename.empty()) return String(); if (etl::basename(full_filename).empty()) return String(); if (full_filename.substr(0, container_prefix.size()) != container_prefix) return full_filename; - if (canvas_filename.empty()) + if (!etl::is_absolute_path(canvas_filename)) return full_filename; String canvas_absolute_filename = etl::absolute_path(canvas_filename); @@ -188,15 +192,16 @@ CanvasFileNaming::make_canvas_independent_filename(const String &canvas_filename String CanvasFileNaming::make_local_filename(const String &canvas_filename, const String &filename) { - if (canvas_filename.empty()) - return String(); - + if (filename.empty()) return String(); String base = etl::basename(filename); if (base.empty()) base = etl::basename(etl::dirname(filename)); if (base.substr(0, container_prefix.size()) == container_prefix) base = base.substr(container_prefix.size()); + if (!etl::is_absolute_path(canvas_filename)) + return base; + String canvas_absolute_filename = etl::absolute_path(canvas_filename); String canvas_path = etl::dirname(canvas_absolute_filename); return canvas_path + ETL_DIRECTORY_SEPARATOR + base; @@ -216,7 +221,7 @@ CanvasFileNaming::make_filesystem_container(const String &filename, FileContaine else { String dir = etl::dirname(filename); - String name = etl::filename_sans_extension(filename); + String name = etl::filename_sans_extension(etl::basename(filename)); String prefix = dir + ETL_DIRECTORY_SEPARATOR + name + "."; FileSystemGroup::Handle group(new FileSystemGroup()); diff --git a/synfig-core/src/synfig/filesystem.cpp b/synfig-core/src/synfig/filesystem.cpp index 3b957d8..83ab7d0 100644 --- a/synfig-core/src/synfig/filesystem.cpp +++ b/synfig-core/src/synfig/filesystem.cpp @@ -156,8 +156,7 @@ bool FileSystem::copy_recursive(Handle from_file_system, const String &from_file if (!to_file_system->directory_create(to_filename)) return false; FileList files; - from_file_system->directory_scan(from_filename, files); - bool success = true; + bool success = from_file_system->directory_scan(from_filename, files); for(FileList::const_iterator i = files.begin(); i != files.end(); ++i) if (!copy_recursive( from_file_system, @@ -172,10 +171,10 @@ bool FileSystem::copy_recursive(Handle from_file_system, const String &from_file String FileSystem::fix_slashes(const String &filename) { - String fixed = filename; + String fixed = etl::cleanup_path(filename); for(size_t i = 0; i < filename.size(); ++i) if (fixed[i] == '\\') fixed[i] = '/'; - return etl::cleanup_path(fixed); + return fixed; } std::istream& diff --git a/synfig-core/src/synfig/filesystemgroup.cpp b/synfig-core/src/synfig/filesystemgroup.cpp index 3452689..3c35c52 100644 --- a/synfig-core/src/synfig/filesystemgroup.cpp +++ b/synfig-core/src/synfig/filesystemgroup.cpp @@ -71,7 +71,7 @@ bool FileSystemGroup::find_system(const String &filename, FileSystem::Handle &ou { out_file_system = i->sub_file_system; out_filename = i->is_separator || clean_filename.size() == i->prefix.size() - ? i->sub_prefix + ? i->sub_prefix + clean_filename.substr(i->prefix.size()) : i->sub_prefix + ETL_DIRECTORY_SEPARATOR + clean_filename.substr(i->prefix.size()); return true; } diff --git a/synfig-core/src/synfig/filesystemtemporary.cpp b/synfig-core/src/synfig/filesystemtemporary.cpp index 1d0d204..5785272 100644 --- a/synfig-core/src/synfig/filesystemtemporary.cpp +++ b/synfig-core/src/synfig/filesystemtemporary.cpp @@ -94,16 +94,17 @@ FileSystemTemporary::is_file(const String &filename) FileMap::const_iterator i = files.find(fix_slashes(filename)); if (i != files.end()) return !i->second.is_removed && !i->second.is_directory; - return file_system && file_system->is_file(filename); + return get_sub_file_system() && get_sub_file_system()->is_file(filename); } bool FileSystemTemporary::is_directory(const String &filename) { + if (filename.empty()) return true; FileMap::const_iterator i = files.find(fix_slashes(filename)); if (i != files.end()) return !i->second.is_removed && i->second.is_directory; - return file_system && file_system->is_directory(filename); + return get_sub_file_system() && get_sub_file_system()->is_directory(filename); } bool @@ -308,7 +309,7 @@ FileSystemTemporary::save_changes( if (to_remove && target_file_system->file_remove(i->second.name)) { processed = true; - files.erase(i); + if (i->second.is_removed) files.erase(i); break; } } diff --git a/synfig-core/src/synfig/filesystemtemporary.h b/synfig-core/src/synfig/filesystemtemporary.h index d586a6f..0766710 100644 --- a/synfig-core/src/synfig/filesystemtemporary.h +++ b/synfig-core/src/synfig/filesystemtemporary.h @@ -54,7 +54,6 @@ namespace synfig String name; String tmp_filename; bool is_directory; - bool was_directory; bool is_removed; inline FileInfo(): is_directory(false), is_removed(false) { } diff --git a/synfig-core/src/synfig/rendering/software/task/tasksurfaceresamplesw.cpp b/synfig-core/src/synfig/rendering/software/task/tasksurfaceresamplesw.cpp index 1729405..457dedf 100644 --- a/synfig-core/src/synfig/rendering/software/task/tasksurfaceresamplesw.cpp +++ b/synfig-core/src/synfig/rendering/software/task/tasksurfaceresamplesw.cpp @@ -37,6 +37,7 @@ #include #include +#include #include "tasksurfaceresamplesw.h" @@ -374,6 +375,9 @@ TaskSurfaceResampleSW::run(RunParams & /* params */) const blend, amount, blend_method ); + + //debug::DebugSurface::save_to_file(a, "TaskSurfaceResampleSW__run__a"); + //debug::DebugSurface::save_to_file(target, "TaskSurfaceResampleSW__run__target"); } return true; diff --git a/synfig-core/src/synfig/valuenodes/valuenode_animatedfile.cpp b/synfig-core/src/synfig/valuenodes/valuenode_animatedfile.cpp index be4026b..cecced3 100644 --- a/synfig-core/src/synfig/valuenodes/valuenode_animatedfile.cpp +++ b/synfig-core/src/synfig/valuenodes/valuenode_animatedfile.cpp @@ -199,15 +199,6 @@ ValueNode_AnimatedFile::load_file(const String &filename, bool forse) for(String::size_type n; (n = optimized_filename.find("%20")) != String::npos;) optimized_filename.replace(n,3," "); -#ifndef _WIN32 - if (is_absolute_path(optimized_filename)) - { - string curpath(cleanup_path(absolute_path(get_parent_canvas()->get_file_path()))); - while(basename(curpath)==".") curpath = dirname(curpath); - optimized_filename = relative_path(curpath, optimized_filename); - } -#endif - String full_filename = CanvasFileNaming::make_full_filename(get_parent_canvas()->get_file_path(), optimized_filename); String local_filename = CanvasFileNaming::make_local_filename(get_parent_canvas()->get_file_name(), full_filename); String independent_filename = CanvasFileNaming::make_canvas_independent_filename(get_parent_canvas()->get_file_path(), full_filename); diff --git a/synfig-studio/src/gui/app.cpp b/synfig-studio/src/gui/app.cpp index e2d9725..4584e22 100644 --- a/synfig-studio/src/gui/app.cpp +++ b/synfig-studio/src/gui/app.cpp @@ -3694,7 +3694,7 @@ App::new_instance() canvas->set_file_name(file_name); canvas->keyframe_list().add(synfig::Keyframe()); - FileSystemTemporary::Handle container(new FileSystemTemporary(FileSystemNative::instance())); + FileSystemTemporary::Handle container(new FileSystemTemporary()); FileSystem::Handle file_system = CanvasFileNaming::make_filesystem(container); canvas->set_identifier(file_system->get_identifier(file_name)); diff --git a/synfig-studio/src/gui/widgets/widget_filename.cpp b/synfig-studio/src/gui/widgets/widget_filename.cpp index 269f68c..1b031a8 100644 --- a/synfig-studio/src/gui/widgets/widget_filename.cpp +++ b/synfig-studio/src/gui/widgets/widget_filename.cpp @@ -30,15 +30,19 @@ # include #endif -#include - #include #include + +#include + +#include + +#include + #include "widgets/widget_filename.h" #include "app.h" #include "canvasview.h" -#include #endif @@ -128,6 +132,8 @@ void Widget_Filename::on_button_choose_pressed() { string filename=entry_filename->get_text(); + filename = synfig::CanvasFileNaming::make_full_filename(canvas->get_file_name(), filename); + if(filename.empty()) filename="."; else @@ -136,26 +142,24 @@ Widget_Filename::on_button_choose_pressed() ETL_DIRECTORY_SEPARATOR + filename); - synfig::Layer::Handle layer(App::get_selected_canvas_view()->get_selection_manager()->get_selected_layer()); + synfig::Layer::Handle layer(App::get_selected_canvas_view()->get_selection_manager()->get_selected_layer()); + + bool selected = false; // Sound layer if (layer->get_name() == "sound") - { - if(App::dialog_open_file_audio(_("Please choose an audio file"), filename, ANIMATION_DIR_PREFERENCE)) - entry_filename->set_text((filename)); - } - + selected = App::dialog_open_file_audio(_("Please choose an audio file"), filename, ANIMATION_DIR_PREFERENCE); + else // Import Image layer - else if (layer->get_name() == "import") - { - if(App::dialog_open_file_image(_("Please choose an image file"), filename, IMAGE_DIR_PREFERENCE)) - entry_filename->set_text((filename)); - } - + if (layer->get_name() == "import") + selected = App::dialog_open_file_image(_("Please choose an image file"), filename, IMAGE_DIR_PREFERENCE); else + selected = App::dialog_open_file(_("Please choose a file"), filename, ANIMATION_DIR_PREFERENCE); + + if (selected) { - if(App::dialog_open_file(_("Please choose a file"), filename, ANIMATION_DIR_PREFERENCE)) - entry_filename->set_text(filename); + filename = synfig::CanvasFileNaming::make_short_filename(canvas->get_file_name(), filename); + entry_filename->set_text(filename); } } diff --git a/synfig-studio/src/gui/widgets/widget_filename.h b/synfig-studio/src/gui/widgets/widget_filename.h index 4793228..959cadd 100644 --- a/synfig-studio/src/gui/widgets/widget_filename.h +++ b/synfig-studio/src/gui/widgets/widget_filename.h @@ -26,11 +26,15 @@ #define __SYNFIG_STUDIO_WIDGET_FILENAME_H /* === H E A D E R S ======================================================= */ + #include #include #include #include +#include + + /* === M A C R O S ========================================================= */ /* === T Y P E D E F S ===================================================== */ @@ -46,6 +50,7 @@ class Widget_Filename : public Gtk::Grid Gtk::Entry *entry_filename; Gtk::Button *button_choose; Gtk::Label *label_find; + etl::handle canvas; void on_button_choose_pressed(); @@ -57,6 +62,7 @@ public: void on_value_changed(); + void set_canvas(etl::handle x) { canvas=x; assert(canvas); } void set_value(const std::string &data); std::string get_value() const; void set_has_frame(bool x); diff --git a/synfig-studio/src/gui/widgets/widget_value.cpp b/synfig-studio/src/gui/widgets/widget_value.cpp index f9d4a05..fd16d72 100644 --- a/synfig-studio/src/gui/widgets/widget_value.cpp +++ b/synfig-studio/src/gui/widgets/widget_value.cpp @@ -39,7 +39,6 @@ #include #include -#include #include "widgets/widget_value.h" @@ -316,7 +315,7 @@ Widget_ValueBase::set_value(const synfig::ValueBase &data) { if(child_param_desc.get_hint()=="filename" || param_desc.get_hint()=="filename") { - filename_widget->set_value(CanvasFileNaming::make_full_filename(canvas->get_file_name(), value.get(string()))); + filename_widget->set_value(value.get(string())); filename_widget->show(); } else if(child_param_desc.get_hint()=="sublayer_name" || param_desc.get_hint()=="sublayer_name") @@ -353,6 +352,14 @@ Widget_ValueBase::set_value(const synfig::ValueBase &data) }catch(...) { synfig::error(__FILE__":%d: Caught something that was thrown",__LINE__); } } +void +Widget_ValueBase::set_canvas(etl::handle x) +{ + assert(x); + canvas=x; + filename_widget->set_canvas(canvas); +} + const synfig::ValueBase & Widget_ValueBase::get_value() { @@ -399,7 +406,7 @@ Widget_ValueBase::get_value() { if(child_param_desc.get_hint()=="filename" || param_desc.get_hint()=="filename") { - value=string(CanvasFileNaming::make_short_filename(canvas->get_file_name(), filename_widget->get_value())); + value=string(filename_widget->get_value()); } else if(child_param_desc.get_hint()=="sublayer_name" || param_desc.get_hint()=="sublayer_name") { value=string(sublayer_widget->get_value()); diff --git a/synfig-studio/src/gui/widgets/widget_value.h b/synfig-studio/src/gui/widgets/widget_value.h index 05c9403..12cc62c 100644 --- a/synfig-studio/src/gui/widgets/widget_value.h +++ b/synfig-studio/src/gui/widgets/widget_value.h @@ -135,7 +135,7 @@ public: //void set_hint(std::string x) { hint=x; } // std::string get_hint() { return hint; } - void set_canvas(etl::handle x) { canvas=x; assert(canvas); } + void set_canvas(etl::handle x); void inside_cellrenderer(); Widget_ValueBase(); ~Widget_ValueBase(); diff --git a/synfig-studio/src/synfigapp/instance.cpp b/synfig-studio/src/synfigapp/instance.cpp index 1adebae..884564f 100644 --- a/synfig-studio/src/synfigapp/instance.cpp +++ b/synfig-studio/src/synfigapp/instance.cpp @@ -360,6 +360,7 @@ Instance::process_filename(const ProcessFilenamesParams ¶ms, const synfig::S { out_filename = new_filename; params.processed_files[full_filename] = out_filename; + info("embed file: %s -> %s", filename.c_str(), out_filename.c_str()); return; } else @@ -371,6 +372,7 @@ Instance::process_filename(const ProcessFilenamesParams ¶ms, const synfig::S out_filename = CanvasFileNaming::make_short_filename(params.canvas->get_file_name(), full_filename); params.processed_files[full_filename] = out_filename; + info("refine filename: %s -> %s", filename.c_str(), out_filename.c_str()); } void @@ -393,10 +395,14 @@ Instance::process_filenames(const ProcessFilenamesParams ¶ms, const synfig:: { if (value.same_type_as(String())) { - params.processed_valuenodes[value_node] = value.get(String()); + String filename = value.get(String()); String new_filename; - process_filename(params, value.get(String()), new_filename); - value_node->set_value(new_filename); + process_filename(params, filename, new_filename); + if (filename != new_filename) + { + params.processed_valuenodes[value_node] = filename; + value_node->set_value(new_filename); + } return; } warning("Cannot process filename for node: %s", node->get_string().c_str()); @@ -453,7 +459,7 @@ Instance::process_filenames(const ProcessFilenamesParams ¶ms, const synfig:: for(ParamVocab::const_iterator i = vocab.begin(); i != vocab.end(); ++i) { Layer::DynamicParamList::const_iterator j = dynamic_params.find(i->get_name()); - ValueNode::Handle value_node = j != dynamic_params.end() ? ValueNode::Handle() : ValueNode::Handle(j->second); + ValueNode::Handle value_node = j == dynamic_params.end() ? ValueNode::Handle() : ValueNode::Handle(j->second); bool is_filename = i->get_hint() == "filename"; if (value_node) @@ -462,17 +468,22 @@ Instance::process_filenames(const ProcessFilenamesParams ¶ms, const synfig:: continue; } - if (!is_filename) - continue; - ValueBase value = layer->get_param(i->get_name()); - if (!value.same_type_as(String())) + + if (value.can_get(Canvas::Handle())) + process_filenames(params, value.get(Canvas::Handle())); + + if (!is_filename || !value.same_type_as(String())) continue; - params.processed_params[std::make_pair(layer, i->get_name())] = value.get(String()); + String filename = value.get(String()); String new_filename; - process_filename(params, value.get(String()), new_filename); - layer->set_param(i->get_name(), new_filename); + process_filename(params, filename, new_filename); + if (filename != new_filename) + { + params.processed_params[std::make_pair(layer, i->get_name())] = filename; + layer->set_param(i->get_name(), new_filename); + } } return; } @@ -602,7 +613,7 @@ Instance::save_as(const synfig::String &file_name) // save bool success = true; if (success) - success = save_canvas(new_canvas_identifier, canvas, !new_container_zip); + success = save_canvas(new_canvas_identifier, canvas, false); if (success) success = new_container->save_changes(); if (success && new_container_zip)