+ if(get_instance()->get_visible_canvases()==1)
+ close_instance();
+ else
+ hide();
+ return false;
+}
+
+static bool _close_instance(etl::handle<Instance> instance)
+{
+ etl::handle<Instance> argh(instance);
+ instance->safe_close();
+ synfig::info("closed");
+ return false;
+}
+
+bool
+CanvasView::close_instance()
+{
+ if (get_work_area()->get_updating())
+ {
+ get_work_area()->stop_updating(true); // stop and mark as cancelled
+
+ // give the workarea chances to stop updating
+ Glib::signal_timeout().connect(
+ sigc::mem_fun(*this, &CanvasView::close_instance),
+ 250);
+ }
+ else
+ Glib::signal_timeout().connect(
+ sigc::bind(sigc::ptr_fun(_close_instance),
+ (etl::handle<Instance>)get_instance()),
+ 250);