Fix some memory leaks.

This commit is contained in:
Jeff Young 2020-04-16 21:57:07 +01:00
parent 66059d6d55
commit cb708aaadb
1 changed files with 10 additions and 18 deletions

View File

@ -984,9 +984,9 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, int aShape, DRAWSEGMEN
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
{ {
if( started ) cleanup();
cleanup();
else if( !started )
{ {
m_frame->PopTool( aTool ); m_frame->PopTool( aTool );
cancelled = true; cancelled = true;
@ -1002,18 +1002,14 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, int aShape, DRAWSEGMEN
} }
else if( evt->IsMoveTool() ) else if( evt->IsMoveTool() )
{ {
if( started ) cleanup();
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();
cleanup();
m_frame->PopTool( aTool ); m_frame->PopTool( aTool );
cancelled = true; cancelled = true;
break; break;
@ -1219,9 +1215,9 @@ bool DRAWING_TOOL::drawArc( const std::string& aTool, DRAWSEGMENT*& aGraphic, bo
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
{ {
if( firstPoint ) cleanup();
cleanup();
else if( !firstPoint )
{ {
m_frame->PopTool( aTool ); m_frame->PopTool( aTool );
cancelled = true; cancelled = true;
@ -1237,18 +1233,14 @@ bool DRAWING_TOOL::drawArc( const std::string& aTool, DRAWSEGMENT*& aGraphic, bo
} }
else if( evt->IsMoveTool() ) else if( evt->IsMoveTool() )
{ {
if( firstPoint ) cleanup();
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();
cleanup();
m_frame->PopTool( aTool ); m_frame->PopTool( aTool );
cancelled = true; cancelled = true;
break; break;