diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index 81fbdb7c8e..73a9e9ffe2 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -150,54 +150,31 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a case PCB_PAD_T: case PCB_MODULE_EDGE_T: case PCB_MODULE_TEXT_T: - { - // Do not allow footprint text removal when not editing a module + // This level can only handle module items when editing modules if( !m_editModules ) break; - bool remove = true; - if( boardItem->Type() == PCB_MODULE_TEXT_T ) { TEXTE_MODULE* text = static_cast( boardItem ); - switch( text->GetType() ) - { - case TEXTE_MODULE::TEXT_is_REFERENCE: - //DisplayError( frame, _( "Cannot delete component reference." ) ); - remove = false; - break; - - case TEXTE_MODULE::TEXT_is_VALUE: - //DisplayError( frame, _( "Cannot delete component value." ) ); - remove = false; - break; - - case TEXTE_MODULE::TEXT_is_DIVERS: // suppress warnings - break; - - default: - wxASSERT( false ); - break; - } + // don't allow deletion of Reference or Value + if( text->GetType() != TEXTE_MODULE::TEXT_is_DIVERS ) + break; } - if( remove ) + view->Remove( boardItem ); + + if( !( changeFlags & CHT_DONE ) ) { - view->Remove( boardItem ); - - if( !( changeFlags & CHT_DONE ) ) - { - MODULE* module = static_cast( boardItem->GetParent() ); - wxASSERT( module && module->Type() == PCB_MODULE_T ); - module->Delete( boardItem ); - } - - board->m_Status_Pcb = 0; // it is done in the legacy view (ratsnest perhaps?) + MODULE* module = static_cast( boardItem->GetParent() ); + wxASSERT( module && module->Type() == PCB_MODULE_T ); + module->Delete( boardItem ); } + board->m_Status_Pcb = 0; // it is done in the legacy view (ratsnest perhaps?) + break; - } // Board items case PCB_LINE_T: // a segment not on copper layers diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 2da0ce0821..25a7e46167 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -892,7 +892,34 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); for( auto item : selection ) - m_commit->Remove( item ); + { + if( m_editModules ) + { + m_commit->Remove( item ); + continue; + } + + switch( item->Type() ) + { + case PCB_MODULE_TEXT_T: + { + auto text = static_cast( item ); + auto parent = static_cast( item->GetParent() ); + + if( text->GetType() == TEXTE_MODULE::TEXT_is_DIVERS ) + { + m_commit->Modify( text ); + getView()->Remove( text ); + parent->Remove( text ); + } + } + break; + + default: + m_commit->Remove( item ); + break; + } + } m_commit->Push( _( "Delete" ) );