From 91ea4242ca86346779840c6e6a65e9ea2a6dcf8b Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 16 Aug 2016 16:56:20 +0200 Subject: [PATCH] Fixed freeze after adding a module --- pcbnew/tools/pcb_editor_control.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index dc4a4f589f..b72d770865 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -250,7 +250,7 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent ) { if( module ) { - board->Delete( module ); // it was added by LoadModuleFromLibrary() + delete module; module = NULL; preview.Clear(); @@ -285,9 +285,13 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent ) module = m_frame->LoadModuleFromLibrary( wxEmptyString, m_frame->Prj().PcbFootprintLibs(), true, NULL ); + if( module == NULL ) continue; + // Module has been added in LoadModuleFromLibrary(), + // so we have to remove it before committing the change @todo LEGACY + board->Remove( module ); module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) ); // Add all the drawable parts to preview