Assign on_instances_moved and put a try/catch to not crash if it accidentally gets called while uninitialzed.

This commit is contained in:
Joseph Lenox 2018-05-12 16:58:29 -05:00
parent 9a4ab21bb8
commit 4e5ed9cdb0
2 changed files with 7 additions and 1 deletions

View File

@ -60,6 +60,8 @@ Plater::Plater(wxWindow* parent, const wxString& title, std::shared_ptr<Settings
canvas2D->on_select_object = std::function<void (ObjIdx obj_idx)>(on_select_object);
canvas2D->on_double_click = std::function<void ()>(on_double_click);
canvas2D->on_right_click = std::function<void (const wxPoint& pos)>([=](const wxPoint& pos){ on_right_click(canvas2D, pos); });
canvas2D->on_instances_moved = std::function<void ()>(on_instances_moved);
canvas3D = new Plate3D(preview_notebook, wxDefaultSize, objects, model, config, settings);
preview_notebook->AddPage(canvas3D, _("3D"));

View File

@ -212,7 +212,11 @@ void Plate2D::mouse_down(wxMouseEvent& e) {
void Plate2D::mouse_up(wxMouseEvent& e) {
if (e.LeftUp()) {
//if (this->drag_object.obj != -1 && this->drag_object.inst != -1) this->on_instances_moved();
try {
if (this->drag_object.obj != -1 && this->drag_object.inst != -1) this->on_instances_moved();
} catch (std::bad_function_call &ex) {
Slic3r::Log::error(LogChannel, L"On_instances_moved was not intialized to a function.");
}
this->drag_start_pos = wxPoint(-1, -1);
this->drag_object = {-1, -1};
this->SetCursor(*wxSTANDARD_CURSOR);