pl_editor: fix a crash when cancelling the "add bitmap dialog" by escape key.

This commit is contained in:
jean-pierre charras 2019-06-20 13:05:23 +02:00
parent 77cefe0c16
commit b8d2fef079
1 changed files with 10 additions and 10 deletions

View File

@ -115,23 +115,24 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
if( evt->IsActivate() )
break;
}
else if( evt->IsClick( BUT_LEFT ) )
{
// First click creates...
if( !item )
{
WS_DATA_ITEM* dataItem = m_frame->AddPageLayoutItem( type );
if( dataItem ) // dataItem = nullptr can happens if the command was cancelled
{
m_frame->SaveCopyInUndoList();
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
WS_DATA_ITEM* dataItem;
dataItem = m_frame->AddPageLayoutItem( type );
item = dataItem->GetDrawItems()[0];
item->SetFlags( IS_NEW | IS_MOVED );
m_selectionTool->AddItemToSel( item );
}
}
// ... and second click places:
else
{
@ -153,7 +154,6 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
}
else if( item && ( evt->IsAction( &PL_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
{
item->GetPeer()->MoveStartPointToUi( (wxPoint) cursorPos );