pleditor: Don't double delete items being placed

The RollbackFromUndo function deletes the items, so
they shouldn't be deleted before it is called.
This commit is contained in:
Ian McInerney 2020-10-09 19:39:03 +01:00
parent 5aa796b5fe
commit b44dbc90fe
1 changed files with 11 additions and 7 deletions

View File

@ -108,12 +108,14 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
auto cleanup = [&] () {
auto cleanup =
[&] ()
{
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
delete item;
item = nullptr;
// There's nothing to roll-back, but we still need to pop the undo stack
// This also deletes the item being placed.
m_frame->RollbackFromUndo();
};
@ -246,6 +248,8 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
if( item )
{
item = nullptr;
// Pop the undo stack and delete the item being placed
m_frame->RollbackFromUndo();
}
else if( evt->IsCancelInteractive() )