Uncomment and fix Layer::simple_clone() to clone a layer without cloning all its...
[synfig.git] / synfig-core / trunk / src / synfig / canvas.cpp
index 5b27e59..c2cf775 100644 (file)
@@ -39,6 +39,7 @@
 #include "time.h"
 #include "context.h"
 #include "layer_pastecanvas.h"
+#include "loadcanvas.h"
 #include <sigc++/bind.h>
 
 #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<synfig::String, etl::loose_handle<Canvas> >::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_();
+               }
        }
 }