diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index df2a1923d5..dcb504b4e4 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -264,9 +264,16 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry ) module->RunOnChildren( [&view] ( BOARD_ITEM* aItem ) { view->Update( aItem ); } ); } - view->Update ( boardItem ); - connectivity->MarkItemNetAsDirty( static_cast( ent.m_copy ) ); + if( ent.m_copy ) + connectivity->MarkItemNetAsDirty( static_cast( ent.m_copy ) ); + connectivity->Update( boardItem ); + view->Update( boardItem ); + + // if no undo entry is needed, the copy would create a memory leak + if( !aCreateUndoEntry ) + delete ent.m_copy; + break; }