From 3f28a1d1cb1fa29f023057981573a3b0bdf0968a Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 31 Jul 2019 23:09:55 -0600 Subject: [PATCH] Cleanup after cancelled add text dialog. Fixes: lp:1838452 * https://bugs.launchpad.net/kicad/+bug/1838452 --- pcbnew/tools/drawing_tool.cpp | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 29b3118413..ff1ee40211 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -291,9 +291,10 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent ) auto cleanup = [&] () { m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); + m_controls->ForceCursorPosition( false ); + m_controls->ShowCursor( true ); m_controls->SetAutoPan( false ); m_controls->CaptureCursor( false ); - m_controls->ShowCursor( true ); delete text; text = NULL; }; @@ -392,23 +393,16 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent ) } ); if( textPcb->GetText().IsEmpty() ) - { - m_controls->ForceCursorPosition( false ); delete textPcb; - } else text = textPcb; } - if( text == NULL ) - continue; - - m_controls->WarpCursor( text->GetPosition(), true ); - m_controls->ForceCursorPosition( false ); - m_controls->CaptureCursor( true ); - m_controls->SetAutoPan( true ); - - m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, text ); + if( text ) + { + m_controls->WarpCursor( text->GetPosition(), true ); + m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, text ); + } } if( placing ) @@ -421,12 +415,13 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, text ); - m_controls->CaptureCursor( false ); - m_controls->SetAutoPan( false ); - m_controls->ShowCursor( true ); - - text = NULL; + text = nullptr; } + + m_controls->ForceCursorPosition( false ); + m_controls->ShowCursor( true ); + m_controls->CaptureCursor( text != nullptr ); + m_controls->SetAutoPan( text != nullptr ); } else if( text && evt->IsMotion() ) {