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.
This commit is contained in:
David Capello 2021-03-26 10:45:46 -03:00
parent 42201a4783
commit 5ba8cecdde
2 changed files with 14 additions and 1 deletions

View File

@ -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

View File

@ -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