From 0eed5175cc183b6fd5222d08c42002c516364790 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 3 Jul 2019 11:42:56 +0100 Subject: [PATCH] Fix crash in Pcbnew drawing tools. Couple of typos: return !cancelled instead of cancel, and some breaks on the wrong side of the braces. Fixes: lp:1835172 * https://bugs.launchpad.net/kicad/+bug/1835172 --- pcbnew/tools/drawing_tool.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 1b266c8d1c..65765752f4 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -952,26 +952,30 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPTPopTool(); cancelled = true; - break; } + + break; } else if( evt->IsActivate() ) { - if( started ) - cleanup(); - if( evt->IsPointEditor() ) { // don't exit (the point editor runs in the background) } else if( evt->IsMoveTool() ) { + if( started ) + cleanup(); + // leave ourselves on the stack so we come back after the move cancelled = true; break; } else { + if( started ) + cleanup(); + m_frame->PopTool(); cancelled = true; break; @@ -1103,7 +1107,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPTCaptureCursor( false ); m_controls->ForceCursorPosition( false ); - return cancelled; + return !cancelled; } @@ -1178,26 +1182,30 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic, bool aImmediateMode ) { m_frame->PopTool(); cancelled = true; - break; } + + break; } else if( evt->IsActivate() ) { - if( firstPoint ) - cleanup(); - if( evt->IsPointEditor() ) { // don't exit (the point editor runs in the background) } else if( evt->IsMoveTool() ) { + if( firstPoint ) + cleanup(); + // leave ourselves on the stack so we come back after the move cancelled = true; break; } else { + if( firstPoint ) + cleanup(); + m_frame->PopTool(); cancelled = true; break; @@ -1293,7 +1301,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic, bool aImmediateMode ) m_controls->CaptureCursor( false ); m_controls->ForceCursorPosition( false ); - return cancelled; + return !cancelled; }