From ad81d530b100b0d616c053dc4d226b996edfb793 Mon Sep 17 00:00:00 2001 From: Filip Sykala - NTB T15p Date: Mon, 3 Apr 2023 16:24:07 +0200 Subject: [PATCH] Fix of freez when undo redo on text with modifier. --- src/slic3r/GUI/Gizmos/GLGizmoBase.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoCut.cpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoCut.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp | 4 +++- src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp | 4 ++-- src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp | 4 ++-- src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoFlatten.cpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoFlatten.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoMeasure.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp | 4 ++-- src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoMove.cpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoMove.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoScale.cpp | 3 +-- src/slic3r/GUI/Gizmos/GLGizmoScale.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmosManager.cpp | 2 +- 26 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp b/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp index 82bcba91f..d2bf3537d 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp @@ -174,7 +174,7 @@ public: /// /// Is called when data (Selection) is changed /// - virtual void data_changed(){}; + virtual void data_changed(bool is_serializing){}; /// /// Implement when want to process mouse events in gizmo diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp index 5d8a69e41..661040451 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp @@ -2510,7 +2510,7 @@ CommonGizmosDataID GLGizmoCut3D::on_get_requirements() const { | int(CommonGizmosDataID::ObjectClipper)); } -void GLGizmoCut3D::data_changed() +void GLGizmoCut3D::data_changed(bool is_serializing) { update_bb(); if (auto oc = m_c->object_clipper()) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp index ee804686e..49d1848e4 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp @@ -256,7 +256,7 @@ protected: std::string get_gizmo_leaving_text() const override { return _u8L("Leaving Cut gizmo"); } std::string get_action_snapshot_name() const override { return _u8L("Cut gizmo editing"); } - void data_changed() override; + void data_changed(bool is_serializing) override; private: void set_center(const Vec3d& center, bool update_tbb = false); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp index 8b134e2e6..ab345a4bb 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp @@ -806,8 +806,10 @@ void GLGizmoEmboss::on_set_state() } } -void GLGizmoEmboss::data_changed() { +void GLGizmoEmboss::data_changed(bool is_serializing) { set_volume_by_selection(); + if (!is_serializing && m_volume == nullptr) + close(); } void GLGizmoEmboss::on_start_dragging() { m_rotate_gizmo.start_dragging(); } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp index 4cfe31898..db8de5e4e 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp @@ -60,8 +60,8 @@ protected: void on_unregister_raycasters_for_picking() override; void on_render_input_window(float x, float y, float bottom_limit) override; bool on_is_selectable() const override { return false; } - void on_set_state() override; - void data_changed() override; // selection changed + void on_set_state() override; + void data_changed(bool is_serializing) override; // selection changed void on_set_hover_id() override{ m_rotate_gizmo.set_hover_id(m_hover_id); } void on_enable_grabber(unsigned int id) override { m_rotate_gizmo.enable_grabber(); } void on_disable_grabber(unsigned int id) override { m_rotate_gizmo.disable_grabber(); } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp index 92b46aaa2..7700e1eef 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp @@ -383,9 +383,9 @@ void GLGizmoFdmSupports::select_facets_by_angle(float threshold_deg, bool block) m_parent.set_as_dirty(); } -void GLGizmoFdmSupports::data_changed() +void GLGizmoFdmSupports::data_changed(bool is_serializing) { - GLGizmoPainterBase::data_changed(); + GLGizmoPainterBase::data_changed(is_serializing); if (! m_c->selection_info()) return; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp index aee669199..ee77573c0 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp @@ -28,7 +28,7 @@ protected: private: bool on_init() override; - void data_changed() override; + void data_changed(bool is_serializing) override; void update_model_object() const override; void update_from_model_object() override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFlatten.cpp b/src/slic3r/GUI/Gizmos/GLGizmoFlatten.cpp index fea8ddc06..398aebb52 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFlatten.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFlatten.cpp @@ -56,7 +56,7 @@ bool GLGizmoFlatten::on_mouse(const wxMouseEvent &mouse_event) return false; } -void GLGizmoFlatten::data_changed() +void GLGizmoFlatten::data_changed(bool is_serializing) { const Selection & selection = m_parent.get_selection(); const ModelObject *model_object = nullptr; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFlatten.hpp b/src/slic3r/GUI/Gizmos/GLGizmoFlatten.hpp index 0444fa217..1701b76a5 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFlatten.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFlatten.hpp @@ -55,7 +55,7 @@ public: /// Return True when use the information otherwise False. bool on_mouse(const wxMouseEvent &mouse_event) override; - void data_changed() override; + void data_changed(bool is_serializing) override; protected: bool on_init() override; std::string on_get_name() const override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp index 374f19edd..91b2bd879 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp @@ -42,7 +42,7 @@ bool GLGizmoHollow::on_init() return true; } -void GLGizmoHollow::data_changed() +void GLGizmoHollow::data_changed(bool is_serializing) { if (! m_c->selection_info()) return; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp b/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp index abfb2503f..025e70b64 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp @@ -24,7 +24,7 @@ class GLGizmoHollow : public GLGizmoSlaBase { public: GLGizmoHollow(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id); - void data_changed() override; + void data_changed(bool is_serializing) override; bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down); void delete_selected_points(); bool is_selection_rectangle_dragging() const override { diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp index e8f6ad4af..d298abdda 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp @@ -454,7 +454,7 @@ bool GLGizmoMeasure::on_mouse(const wxMouseEvent &mouse_event) return false; } -void GLGizmoMeasure::data_changed() +void GLGizmoMeasure::data_changed(bool is_serializing) { m_parent.toggle_sla_auxiliaries_visibility(false, nullptr, -1); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.hpp b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.hpp index cc43b068e..6a8f21a19 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.hpp @@ -156,7 +156,7 @@ public: /// Return True when use the information otherwise False. bool on_mouse(const wxMouseEvent &mouse_event) override; - void data_changed() override; + void data_changed(bool is_serializing) override; bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp index fd7963050..516a2b258 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp @@ -147,9 +147,9 @@ void GLGizmoMmuSegmentation::render_painter_gizmo() glsafe(::glDisable(GL_BLEND)); } -void GLGizmoMmuSegmentation::data_changed() +void GLGizmoMmuSegmentation::data_changed(bool is_serializing) { - GLGizmoPainterBase::data_changed(); + GLGizmoPainterBase::data_changed(is_serializing); if (m_state != On || wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptFFF || wxGetApp().extruders_edited_cnt() <= 1) return; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp index ee32c4596..21138c530 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp @@ -90,7 +90,7 @@ public: void render_painter_gizmo() override; - void data_changed() override; + void data_changed(bool is_serializing) override; void render_triangles(const Selection& selection) const override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp index 3d697c63c..556d5b61e 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp @@ -34,7 +34,7 @@ bool GLGizmoMove3D::on_mouse(const wxMouseEvent &mouse_event) { return use_grabbers(mouse_event); } -void GLGizmoMove3D::data_changed() { +void GLGizmoMove3D::data_changed(bool is_serializing) { m_grabbers[2].enabled = !m_parent.get_selection().is_wipe_tower(); } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMove.hpp b/src/slic3r/GUI/Gizmos/GLGizmoMove.hpp index 371cda80a..b68747920 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMove.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMove.hpp @@ -47,7 +47,7 @@ public: /// /// Detect reduction of move for wipetover on selection change /// - void data_changed() override; + void data_changed(bool is_serializing) override; protected: bool on_init() override; std::string on_get_name() const override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp index 0a2f9f098..d574f7b56 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp @@ -31,7 +31,7 @@ GLGizmoPainterBase::~GLGizmoPainterBase() s_sphere.reset(); } -void GLGizmoPainterBase::data_changed() +void GLGizmoPainterBase::data_changed(bool is_serializing) { if (m_state != On) return; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp index 1fd718a25..007b959e7 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp @@ -83,7 +83,7 @@ private: public: GLGizmoPainterBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id); ~GLGizmoPainterBase() override; - void data_changed() override; + void data_changed(bool is_serializing) override; virtual bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down); // Following function renders the triangles and cursor. Having this separated diff --git a/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp b/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp index 2636486a7..677f2589e 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp @@ -535,7 +535,7 @@ bool GLGizmoRotate3D::on_mouse(const wxMouseEvent &mouse_event) return use_grabbers(mouse_event); } -void GLGizmoRotate3D::data_changed() { +void GLGizmoRotate3D::data_changed(bool is_serializing) { if (m_parent.get_selection().is_wipe_tower()) { m_gizmos[0].disable_grabber(); m_gizmos[1].disable_grabber(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp b/src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp index a1bb2ee44..bbc32ec7a 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp @@ -138,7 +138,7 @@ public: /// Return True when use the information otherwise False. bool on_mouse(const wxMouseEvent &mouse_event) override; - void data_changed() override; + void data_changed(bool is_serializing) override; protected: bool on_init() override; std::string on_get_name() const override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp b/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp index 5e6ab1ae6..1a7251ddf 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp @@ -99,8 +99,7 @@ void GLGizmoScale3D::enable_ununiversal_scale(bool enable) m_grabbers[i].enabled = enable; } -void GLGizmoScale3D::data_changed() -{ +void GLGizmoScale3D::data_changed(bool is_serializing) { set_scale(Vec3d::Ones()); } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoScale.hpp b/src/slic3r/GUI/Gizmos/GLGizmoScale.hpp index d0b239c33..6a7b4a331 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoScale.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoScale.hpp @@ -61,7 +61,7 @@ public: /// Return True when use the information otherwise False. bool on_mouse(const wxMouseEvent &mouse_event) override; - void data_changed() override; + void data_changed(bool is_serializing) override; void enable_ununiversal_scale(bool enable); protected: virtual bool on_init() override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index 5ff491d2d..109490cc7 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -49,7 +49,7 @@ bool GLGizmoSlaSupports::on_init() return true; } -void GLGizmoSlaSupports::data_changed() +void GLGizmoSlaSupports::data_changed(bool is_serializing) { if (! m_c->selection_info()) return; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp index bb0513682..c098905aa 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp @@ -55,7 +55,7 @@ private: public: GLGizmoSlaSupports(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id); virtual ~GLGizmoSlaSupports() = default; - void data_changed() override; + void data_changed(bool is_serializing) override; bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down); void delete_selected_points(bool force = false); //ClippingPlane get_sla_clipping_plane() const; diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index d6dd6ff3e..98dd15137 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -223,7 +223,7 @@ void GLGizmosManager::update_data() m_common_gizmos_data->update(get_current() ? get_current()->get_requirements() : CommonGizmosDataID(0)); - if (m_current != Undefined) m_gizmos[m_current]->data_changed(); + if (m_current != Undefined) m_gizmos[m_current]->data_changed(m_serializing); } bool GLGizmosManager::is_running() const