X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fcanvas.cpp;h=2e0144bd686472d70d933cbb8908e4d16338e632;hb=71d498a6e0600d4a46b5416cfc765342f869cd34;hp=5b27e5940fc993c7e214913f30cca61c4353124b;hpb=a3497cc298f84064e55264320443be79547a02c1;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/canvas.cpp b/synfig-core/trunk/src/synfig/canvas.cpp index 5b27e59..2e0144b 100644 --- a/synfig-core/trunk/src/synfig/canvas.cpp +++ b/synfig-core/trunk/src/synfig/canvas.cpp @@ -39,6 +39,7 @@ #include "time.h" #include "context.h" #include "layer_pastecanvas.h" +#include "loadcanvas.h" #include #endif @@ -51,6 +52,8 @@ namespace synfig { extern Canvas::Handle open_canvas(const String &filename, Str /* === M A C R O S ========================================================= */ +#define ALLOW_CLONE_NON_INLINE_CANVASES + struct _CanvasCounter { static int counter; @@ -780,7 +783,9 @@ Canvas::clone(const GUID& deriv_guid)const { name=get_id()+"_CLONE"; +#ifndef ALLOW_CLONE_NON_INLINE_CANVASES throw runtime_error("Cloning of non-inline canvases is not yet supported"); +#endif // ALLOW_CLONE_NON_INLINE_CANVASES } Handle canvas(new Canvas(name)); @@ -956,8 +961,24 @@ Canvas::set_file_name(const String &file_name) parent()->set_file_name(file_name); else { + String old_name(file_name_); file_name_=file_name; - signal_file_name_changed_(); + + // when a canvas is made, its name is "" + // then, before it's saved or even edited, it gets a name like "Synfig Animation 23", in the local language + // we don't want to register the canvas' filename in the canvas map until it gets a real filename + if (old_name != "") + { + file_name_=file_name; + std::map >::iterator iter; + for(iter=get_open_canvas_map().begin();iter!=get_open_canvas_map().end();++iter) + if(iter->second==this) + break; + if (iter == get_open_canvas_map().end()) + CanvasParser::register_canvas_in_map(this, file_name); + else + signal_file_name_changed_(); + } } } @@ -1215,7 +1236,8 @@ synfig::optimize_layers(Time time, Context context, Canvas::Handle op_canvas, bo !composite->reads_context()) { Canvas::Handle sub_canvas(Canvas::create_inline(op_canvas)); - sub_canvas->push_back(composite = composite->clone()); + // don't use clone() because it re-randomizes the seeds of any random valuenodes + sub_canvas->push_back(composite = composite->simple_clone()); layer = Layer::create("PasteCanvas"); composite->set_description(strprintf("Wrapped clone of '%s'", composite->get_non_empty_description().c_str())); layer->set_description(strprintf("PasteCanvas wrapper for '%s'", composite->get_non_empty_description().c_str())); @@ -1363,3 +1385,10 @@ Canvas::rename_group(const String&old_name,const String&new_name) (*iter)->add_to_group(new_name); } } + +void +Canvas::register_external_canvas(String file_name, Handle canvas) +{ + if(!is_absolute_path(file_name)) file_name = get_file_path()+ETL_DIRECTORY_SEPARATOR+file_name; + externals_[file_name] = canvas; +}