From 2dd04ea43a7d8336201b5ac179fcf1bfbe0a79b8 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 18 Nov 2022 17:07:02 +0000 Subject: [PATCH] Protect move tool from re-entrancy. m_dragInProgress is usually sufficient, except when we haven't started one yet. In any case, conflating the two is probably a bad idea. Fixes https://gitlab.com/kicad/code/kicad/issues/12936 (cherry picked from commit bc271a8d15b8f2a07cf2db62080a6225af6ad6f1) --- eeschema/tools/sch_move_tool.cpp | 6 ++++++ eeschema/tools/sch_move_tool.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index f66b97a056..a13aa8c197 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -47,6 +47,7 @@ SCH_MOVE_TOOL::SCH_MOVE_TOOL() : EE_TOOL_BASE( "eeschema.InteractiveMove" ), + m_inMoveTool( false ), m_moveInProgress( false ), m_isDrag( false ), m_moveOffset( 0, 0 ) @@ -126,6 +127,11 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) return 0; } + if( m_inMoveTool ) // Must come after m_moveInProgress checks above... + return 0; + + REENTRANCY_GUARD guard( &m_inMoveTool ); + // Be sure that there is at least one item that we can move. If there's no selection try // looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection). EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::MovableItems ); diff --git a/eeschema/tools/sch_move_tool.h b/eeschema/tools/sch_move_tool.h index 38529c120e..5f15cdf849 100644 --- a/eeschema/tools/sch_move_tool.h +++ b/eeschema/tools/sch_move_tool.h @@ -81,6 +81,9 @@ private: void setTransitions() override; private: + ///< Re-entrancy guard + bool m_inMoveTool; + ///< Flag determining if anything is being dragged right now bool m_moveInProgress; bool m_isDrag;