Fixed a crash when removing zones using the Global Deletion dialog

Fixes: lp:1635266
* https://bugs.launchpad.net/kicad/+bug/1635266
This commit is contained in:
Maciej Suminski 2016-10-20 17:15:27 +02:00
parent ce83410c52
commit 74b5858665
2 changed files with 21 additions and 30 deletions

View File

@ -43,7 +43,8 @@ COMMIT::~COMMIT()
COMMIT& COMMIT::Stage( EDA_ITEM* aItem, CHANGE_TYPE aChangeType ) COMMIT& COMMIT::Stage( EDA_ITEM* aItem, CHANGE_TYPE aChangeType )
{ {
assert( aChangeType != ( CHT_MODIFY | CHT_DONE ) ); // CHT_MODIFY and CHT_DONE are not compatible // CHT_MODIFY and CHT_DONE are not compatible
assert( ( aChangeType & ( CHT_MODIFY | CHT_DONE ) ) != ( CHT_MODIFY | CHT_DONE ) );
int flag = aChangeType & CHT_FLAGS; int flag = aChangeType & CHT_FLAGS;
@ -55,6 +56,7 @@ COMMIT& COMMIT::Stage( EDA_ITEM* aItem, CHANGE_TYPE aChangeType )
return *this; return *this;
case CHT_REMOVE: case CHT_REMOVE:
assert( m_changedItems.find( aItem ) == m_changedItems.end() );
makeEntry( aItem, CHT_REMOVE | flag ); makeEntry( aItem, CHT_REMOVE | flag );
return *this; return *this;

View File

@ -111,7 +111,6 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
BOARD* pcb = m_Parent->GetBoard(); BOARD* pcb = m_Parent->GetBoard();
BOARD_COMMIT commit( m_Parent ); BOARD_COMMIT commit( m_Parent );
BOARD_ITEM* item; BOARD_ITEM* item;
BOARD_ITEM* nextitem;
LSET layers_filter = LSET().set(); LSET layers_filter = LSET().set();
@ -130,47 +129,39 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
commit.Remove( item ); commit.Remove( item );
gen_rastnest = true; gen_rastnest = true;
} }
else
{
area_index++;
}
area_index++;
item = pcb->GetArea( area_index ); item = pcb->GetArea( area_index );
} }
} }
if( delAll || m_DelDrawings->GetValue() || m_DelBoardEdges->GetValue() ) bool delDrawings = m_DelDrawings->GetValue() || m_DelBoardEdges->GetValue();
bool delTexts = m_DelTexts->GetValue();
if( delAll || delDrawings || delTexts )
{ {
// Layer mask for texts
LSET del_text_layers = layers_filter;
// Layer mask for drawings
LSET masque_layer; LSET masque_layer;
if( m_DelDrawings->GetValue() ) if( m_DelDrawings->GetValue() )
masque_layer = LSET::AllNonCuMask().set( Edge_Cuts, false ); masque_layer = LSET::AllNonCuMask().set( Edge_Cuts, false );
if( m_DelBoardEdges->GetValue() ) if( m_DelBoardEdges->GetValue() )
masque_layer.set( Edge_Cuts ); masque_layer.set( Edge_Cuts );
masque_layer &= layers_filter; masque_layer &= layers_filter;
for( item = pcb->m_Drawings; item; item = nextitem ) for( item = pcb->m_Drawings; item; item = item->Next() )
{ {
nextitem = item->Next(); KICAD_T type = item->Type();
LAYER_NUM layer = item->GetLayer();
if( delAll || ( item->Type() == PCB_LINE_T && masque_layer[item->GetLayer()] ) ) if( delAll
{ || ( type == PCB_LINE_T && delDrawings && masque_layer[layer] )
commit.Remove( item ); || ( type == PCB_TEXT_T && delTexts && del_text_layers[layer] ) )
}
}
}
if( delAll || m_DelTexts->GetValue() )
{
LSET del_text_layers = layers_filter;
for( item = pcb->m_Drawings; item; item = nextitem )
{
nextitem = item->Next();
if( delAll || ( item->Type() == PCB_TEXT_T && del_text_layers[item->GetLayer()] ) )
{ {
commit.Remove( item ); commit.Remove( item );
} }
@ -179,10 +170,8 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
if( delAll || m_DelModules->GetValue() ) if( delAll || m_DelModules->GetValue() )
{ {
for( item = pcb->m_Modules; item; item = nextitem ) for( item = pcb->m_Modules; item; item = item->Next() )
{ {
nextitem = item->Next();
bool del_fp = delAll; bool del_fp = delAll;
if( layers_filter[item->GetLayer()] && if( layers_filter[item->GetLayer()] &&