@@ -252,6 +252,15 @@ bool get_paragraph(synfig::String& text)
252252 return App::dialog_paragraph (_ (" Text Paragraph" ), _ (" Enter text here:" ), text);
253253}
254254
255+ static bool
256+ is_layer_deleted (const synfig::Layer::ConstHandle& layer)
257+ {
258+ if (Canvas::LooseHandle layer_canvas = layer->get_canvas ())
259+ return std::find (layer_canvas->begin (), layer_canvas->end (), layer) == layer_canvas->end ();
260+
261+ return true ;
262+ }
263+
255264/* === M E T H O D S ======================================================= */
256265
257266CellRenderer_ValueBase::CellRenderer_ValueBase ():
@@ -286,6 +295,12 @@ CellRenderer_ValueBase::~CellRenderer_ValueBase()
286295 " CellRenderer_ValueBase::~CellRenderer_ValueBase(): Deleted" );
287296}
288297
298+ void
299+ CellRenderer_ValueBase::set_canvas_interface (const etl::loose_handle<synfigapp::CanvasInterface>& x)
300+ {
301+ canvas_interface = x;
302+ }
303+
289304void
290305CellRenderer_ValueBase::string_edited_ (const Glib::ustring& path, const Glib::ustring& str)
291306{
@@ -558,6 +573,26 @@ CellRenderer_ValueBase::activate_vfunc( GdkEvent* event,
558573void
559574CellRenderer_ValueBase::gradient_edited (synfig::Gradient gradient, Glib::ustring path)
560575{
576+ synfigapp::ValueDesc vd = App::dialog_gradient->get_value_desc ();
577+ if (vd.is_valid ()) {
578+ if (vd.parent_is_layer ()) {
579+ if (is_layer_deleted (vd.get_layer ()))
580+ return ;
581+ }
582+ // do not emit signal_edited_ : gradient dialog may be opened by other cell
583+ // and would try to update the parameter related to current one
584+ // as it just remembered its parameter tree path
585+ // Example:
586+ // 1. Create a region layer
587+ // 2. Create a gradient layer
588+ // 3. Click on gradient parameter to edit it
589+ // 4. Without closing gradient dialog, select the region layer instead
590+ // 5. Try to edit the gradient
591+ // 6. Error Message appears
592+ canvas_interface->change_value (vd, gradient);
593+ return ;
594+ }
595+
561596 ValueBase old_value (property_value_.get_value ());
562597 ValueBase value (gradient);
563598 if (old_value != value)
@@ -567,6 +602,26 @@ CellRenderer_ValueBase::gradient_edited(synfig::Gradient gradient, Glib::ustring
567602void
568603CellRenderer_ValueBase::color_edited (synfig::Color color, Glib::ustring path)
569604{
605+ synfigapp::ValueDesc vd = App::dialog_color->get_value_desc ();
606+ if (vd.is_valid ()) {
607+ if (vd.parent_is_layer ()) {
608+ if (is_layer_deleted (vd.get_layer ()))
609+ return ;
610+ }
611+ // do not emit signal_edited_ : color dialog may be opened by other cell
612+ // and would try to update the parameter related to current one
613+ // as it just remembered its parameter tree path
614+ // Example:
615+ // 1. Create a region layer
616+ // 2. Create an outline layer
617+ // 3. Click on color parameter to edit it
618+ // 4. Without closing color dialog, select the region layer instead
619+ // 5. Try to edit the color
620+ // 6. Error Message appears
621+ canvas_interface->change_value (vd, color);
622+ return ;
623+ }
624+
570625 ValueBase old_value (property_value_.get_value ());
571626 ValueBase value (color);
572627 if (old_value != value)
@@ -608,6 +663,7 @@ CellRenderer_ValueBase::start_editing_vfunc(
608663 {
609664 App::dialog_gradient->reset ();
610665 App::dialog_gradient->set_gradient ( data.get (Gradient ()) );
666+ App::dialog_gradient->set_value_desc (get_value_desc ());
611667 App::dialog_gradient->signal_edited ().connect (
612668 sigc::bind (
613669 sigc::mem_fun (*this , &studio::CellRenderer_ValueBase::gradient_edited),
@@ -623,6 +679,7 @@ CellRenderer_ValueBase::start_editing_vfunc(
623679 {
624680 App::dialog_color->reset ();
625681 App::dialog_color->set_color ( data.get (Color ()) );
682+ App::dialog_color->set_value_desc (get_value_desc ());
626683 App::dialog_color->signal_edited ().connect (
627684 sigc::bind (
628685 sigc::mem_fun (*this , &studio::CellRenderer_ValueBase::color_edited),
0 commit comments