#include "time.h"
#include "context.h"
#include "layer_pastecanvas.h"
+#include "loadcanvas.h"
#include <sigc++/bind.h>
#endif
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_();
+ }
}
}
return canvas;
}
+void
+CanvasParser::register_canvas_in_map(Canvas::Handle canvas, String as)
+{
+ get_open_canvas_map()[etl::absolute_path(as)]=canvas;
+ canvas->signal_deleted().connect(sigc::bind(sigc::ptr_fun(_remove_from_open_canvas_map),canvas.get()));
+ canvas->signal_file_name_changed().connect(sigc::bind(sigc::ptr_fun(_canvas_file_name_changed),canvas.get()));
+}
+
Canvas::Handle
CanvasParser::parse_from_file_as(const String &file_,const String &as_,String &errors)
{
{
Canvas::Handle canvas(parse_canvas(parser.get_document()->get_root_node(),0,false,as));
if (!canvas) return canvas;
- get_open_canvas_map()[etl::absolute_path(as)]=canvas;
- canvas->signal_deleted().connect(sigc::bind(sigc::ptr_fun(_remove_from_open_canvas_map),canvas.get()));
- canvas->signal_file_name_changed().connect(sigc::bind(sigc::ptr_fun(_canvas_file_name_changed),canvas.get()));
+ register_canvas_in_map(canvas, as);
const ValueNodeList& value_node_list(canvas->value_node_list());
const synfig::String& get_errors_text()const { return errors_text; }
const synfig::String& get_warnings_text()const { return warnings_text; }
+ static void register_canvas_in_map(Canvas::Handle canvas, String as);
+
//! \todo writeme
Canvas::Handle parse_from_file_as(const String &filename,const String &as,String &errors);