synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
Layer::Handle layer(get_canvas_interface()->add_layer_to("curve_gradient",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ group.cancel();
+ throw String(_("Unable to create layer"));
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Gradient"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
Layer::Handle layer(get_canvas_interface()->add_layer_to("plant",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ group.cancel();
+ throw String(_("Unable to create layer"));
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Plant"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
Layer::Handle layer(get_canvas_interface()->add_layer_to("region",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ group.cancel();
+ throw String(_("Unable to create layer"));
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Region"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
Layer::Handle layer(get_canvas_interface()->add_layer_to("outline",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ group.cancel();
+ throw String(_("Unable to create layer"));
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Outline"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
get_falloff() >= 0 && get_falloff() < CIRCLE_NUM_FALLOFF)
{
layer=get_canvas_interface()->add_layer_to("circle",canvas,depth);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_param("origin",p1);
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
Layer::Handle layer(get_canvas_interface()->add_layer_to("curve_gradient",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Gradient"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
Layer::Handle layer(get_canvas_interface()->add_layer_to("plant",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Plant"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
Layer::Handle layer(get_canvas_interface()->add_layer_to("region",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Region"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
if (get_layer_outline_flag())
{
Layer::Handle layer(get_canvas_interface()->add_layer_to("outline",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Outline"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
Duckmatic::Type old_duckmask;
void fill_last_stroke();
- void fill_last_stroke_and_unselect_other_layers();
+ Smach::event_result fill_last_stroke_and_unselect_other_layers();
Smach::event_result new_bline(std::list<synfig::BLinePoint> bline,bool loop_bline_flag,float radius);
// fill_last_stroke() will take care of clearing the selection if we're calling it
if(get_outline_flag() && get_region_flag())
- fill_last_stroke_and_unselect_other_layers();
+ {
+ if (fill_last_stroke_and_unselect_other_layers() == Smach::RESULT_ERROR)
+ {
+ get_canvas_view()->get_selection_manager()->set_selected_layers(layer_list);
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return Smach::RESULT_ERROR;
+ }
+ }
else
get_canvas_interface()->get_selection_manager()->clear_selected_layers();
if(get_outline_flag())
{
layer=get_canvas_interface()->add_layer_to("outline",canvas,depth);
+ if (!layer)
+ {
+ get_canvas_view()->get_selection_manager()->set_selected_layers(layer_list);
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return Smach::RESULT_ERROR;
+ }
layer->set_description(get_id()+_(" Outline"));
}
else
{
layer=get_canvas_interface()->add_layer_to("region",canvas,depth);
+ if (!layer)
+ {
+ get_canvas_view()->get_selection_manager()->set_selected_layers(layer_list);
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return Smach::RESULT_ERROR;
+ }
layer->set_description(get_id()+_(" Region"));
}
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
layer=get_canvas_interface()->add_layer_to("region",canvas,depth);
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return Smach::RESULT_ERROR;
+ }
layer->set_param("color",synfigapp::Main::get_background_color());
if(get_feather())
{
}
}
-void
+Smach::event_result
StateDraw_Context::fill_last_stroke_and_unselect_other_layers()
{
if(!last_stroke)
- return;
+ return Smach::RESULT_OK;
synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Fill Stroke"));
get_canvas_interface()->get_selection_manager()->clear_selected_layers();
layer=get_canvas_interface()->add_layer_to("region", canvas, depth);
- assert(layer);
+ if (!layer) return Smach::RESULT_ERROR;
layer->set_param("color",synfigapp::Main::get_background_color());
layer->set_description(last_stroke_id + _(" Region"));
{
get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
group.cancel();
- return;
+ return Smach::RESULT_OK;
}
get_canvas_view()->get_selection_manager()->set_selected_layer(layer);
+ return Smach::RESULT_OK;
}
void
case GRADIENT_INTERPOLATION_LINEAR:
layer=get_canvas_interface()->add_layer_to("linear_gradient",canvas,depth);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer->set_param("p1",p1);
get_canvas_interface()->signal_layer_param_changed()(layer,"p1");
layer->set_param("p2",p2);
break;
case GRADIENT_RADIAL:
layer=get_canvas_interface()->add_layer_to("radial_gradient",canvas,depth);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer->set_param("center",p1);
get_canvas_interface()->signal_layer_param_changed()(layer,"center");
layer->set_param("radius",(p2-p1).mag());
break;
case GRADIENT_CONICAL:
layer=get_canvas_interface()->add_layer_to("conical_gradient",canvas,depth);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer->set_param("center",p1);
get_canvas_interface()->signal_layer_param_changed()(layer,"center");
{
break;
case GRADIENT_SPIRAL:
layer=get_canvas_interface()->add_layer_to("spiral_gradient",canvas,depth);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer->set_param("center",p1);
get_canvas_interface()->signal_layer_param_changed()(layer,"center");
layer->set_param("radius",(p2-p1).mag());
if (get_layer_polygon_flag())
{
layer=get_canvas_interface()->add_layer_to("polygon",canvas,depth);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_param("invert",get_invert());
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
Layer::Handle layer(get_canvas_interface()->add_layer_to("curve_gradient",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Gradient"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
Layer::Handle layer(get_canvas_interface()->add_layer_to("plant",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Plant"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
Layer::Handle layer(get_canvas_interface()->add_layer_to("region",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Region"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
if (get_layer_outline_flag())
{
Layer::Handle layer(get_canvas_interface()->add_layer_to("outline",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Outline"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
if (get_layer_rectangle_flag())
{
layer=get_canvas_interface()->add_layer_to("rectangle",canvas,depth);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_param("point1",p1);
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
Layer::Handle layer(get_canvas_interface()->add_layer_to("curve_gradient",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Gradient"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
Layer::Handle layer(get_canvas_interface()->add_layer_to("plant",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Plant"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
Layer::Handle layer(get_canvas_interface()->add_layer_to("region",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Region"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
if (get_layer_outline_flag())
{
Layer::Handle layer(get_canvas_interface()->add_layer_to("outline",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Outline"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
if (get_layer_star_flag())
{
layer=get_canvas_interface()->add_layer_to("star",canvas,depth);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_param("origin",p1);
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
Layer::Handle layer(get_canvas_interface()->add_layer_to("curve_gradient",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Gradient"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
Layer::Handle layer(get_canvas_interface()->add_layer_to("plant",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Plant"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
Layer::Handle layer(get_canvas_interface()->add_layer_to("region",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Region"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
if (get_layer_outline_flag())
{
Layer::Handle layer(get_canvas_interface()->add_layer_to("outline",canvas,depth));
- assert(layer);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_description(get_id()+_(" Outline"));
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
App::dialog_entry(_("Text Entry"), _("Enter text here:"), text);
layer=get_canvas_interface()->add_layer_to("text",canvas,depth);
+ if (!layer)
+ {
+ get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+ group.cancel();
+ return;
+ }
layer_selection.push_back(layer);
layer->set_param("origin",point);