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
This commit is contained in:
Jeff Young 2019-07-03 11:42:56 +01:00
parent adf06791eb
commit 0eed5175cc
1 changed files with 18 additions and 10 deletions

View File

@ -952,26 +952,30 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
{ {
m_frame->PopTool(); m_frame->PopTool();
cancelled = true; cancelled = true;
break;
} }
break;
} }
else if( evt->IsActivate() ) else if( evt->IsActivate() )
{ {
if( started )
cleanup();
if( evt->IsPointEditor() ) if( evt->IsPointEditor() )
{ {
// don't exit (the point editor runs in the background) // don't exit (the point editor runs in the background)
} }
else if( evt->IsMoveTool() ) else if( evt->IsMoveTool() )
{ {
if( started )
cleanup();
// leave ourselves on the stack so we come back after the move // leave ourselves on the stack so we come back after the move
cancelled = true; cancelled = true;
break; break;
} }
else else
{ {
if( started )
cleanup();
m_frame->PopTool(); m_frame->PopTool();
cancelled = true; cancelled = true;
break; break;
@ -1103,7 +1107,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
m_controls->CaptureCursor( false ); m_controls->CaptureCursor( false );
m_controls->ForceCursorPosition( false ); m_controls->ForceCursorPosition( false );
return cancelled; return !cancelled;
} }
@ -1178,26 +1182,30 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic, bool aImmediateMode )
{ {
m_frame->PopTool(); m_frame->PopTool();
cancelled = true; cancelled = true;
break;
} }
break;
} }
else if( evt->IsActivate() ) else if( evt->IsActivate() )
{ {
if( firstPoint )
cleanup();
if( evt->IsPointEditor() ) if( evt->IsPointEditor() )
{ {
// don't exit (the point editor runs in the background) // don't exit (the point editor runs in the background)
} }
else if( evt->IsMoveTool() ) else if( evt->IsMoveTool() )
{ {
if( firstPoint )
cleanup();
// leave ourselves on the stack so we come back after the move // leave ourselves on the stack so we come back after the move
cancelled = true; cancelled = true;
break; break;
} }
else else
{ {
if( firstPoint )
cleanup();
m_frame->PopTool(); m_frame->PopTool();
cancelled = true; cancelled = true;
break; break;
@ -1293,7 +1301,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic, bool aImmediateMode )
m_controls->CaptureCursor( false ); m_controls->CaptureCursor( false );
m_controls->ForceCursorPosition( false ); m_controls->ForceCursorPosition( false );
return cancelled; return !cancelled;
} }