From 5ba8cecddebb789bf2266a1600ea4c7f56fc34b7 Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 26 Mar 2021 10:45:46 -0300 Subject: [PATCH] Fix a crash pressing (and keeping pressed) Ctrl+Z (Command+Z) This tries to avoid calling onBeforeCommandExecution() after we are going to the previous state. This might be a problem on all states that are using a scoped_connection to disconnect from the app::Context signal in the destructor (instead of in the onBeforePopState). Something to fix next for all other states. --- src/app/ui/editor/moving_cel_state.cpp | 11 +++++++++++ src/app/ui/editor/moving_cel_state.h | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/app/ui/editor/moving_cel_state.cpp b/src/app/ui/editor/moving_cel_state.cpp index 403dafe7b..5f33ebf83 100644 --- a/src/app/ui/editor/moving_cel_state.cpp +++ b/src/app/ui/editor/moving_cel_state.cpp @@ -130,6 +130,16 @@ MovingCelState::MovingCelState(Editor* editor, } } +MovingCelState::~MovingCelState() +{ + m_ctxConn.disconnect(); +} + +void MovingCelState::onBeforePopState(Editor* editor) +{ + m_ctxConn.disconnect(); +} + bool MovingCelState::onMouseUp(Editor* editor, MouseMessage* msg) { Doc* document = editor->document(); @@ -357,4 +367,5 @@ void MovingCelState::onBeforeCommandExecution(CommandExecutionEvent& ev) } ev.cancel(); } + } // namespace app diff --git a/src/app/ui/editor/moving_cel_state.h b/src/app/ui/editor/moving_cel_state.h index 52eeeb657..f0b0955f6 100644 --- a/src/app/ui/editor/moving_cel_state.h +++ b/src/app/ui/editor/moving_cel_state.h @@ -44,7 +44,9 @@ namespace app { ui::MouseMessage* msg, const HandleType handle, const MovingCelCollect& collect); + ~MovingCelState(); + virtual void onBeforePopState(Editor* editor) override; virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) override; virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) override; virtual bool onKeyDown(Editor* editor, ui::KeyMessage* msg) override; @@ -72,7 +74,7 @@ namespace app { HandleType m_handle; Editor* m_editor; - obs::scoped_connection m_ctxConn; + obs::connection m_ctxConn; }; } // namespace app