From 427c7c702792439966d8a8d2ffb8f580bae8f6db Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sat, 12 May 2018 16:58:29 -0500 Subject: [PATCH] Assign on_instances_moved and put a try/catch to not crash if it accidentally gets called while uninitialzed. --- src/GUI/Plater.cpp | 2 ++ src/GUI/Plater/Plate2D.cpp | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/GUI/Plater.cpp b/src/GUI/Plater.cpp index a33fa713e..4e299aaa6 100644 --- a/src/GUI/Plater.cpp +++ b/src/GUI/Plater.cpp @@ -60,6 +60,8 @@ Plater::Plater(wxWindow* parent, const wxString& title, std::shared_ptron_select_object = std::function(on_select_object); canvas2D->on_double_click = std::function(on_double_click); canvas2D->on_right_click = std::function([=](const wxPoint& pos){ on_right_click(canvas2D, pos); }); + canvas2D->on_instances_moved = std::function(on_instances_moved); + canvas3D = new Plate3D(preview_notebook, wxDefaultSize, objects, model, config, settings); preview_notebook->AddPage(canvas3D, _("3D")); diff --git a/src/GUI/Plater/Plate2D.cpp b/src/GUI/Plater/Plate2D.cpp index 3e865086b..10f9122e5 100644 --- a/src/GUI/Plater/Plate2D.cpp +++ b/src/GUI/Plater/Plate2D.cpp @@ -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);