Clean up several bugs in Graphics Cleaner.

See bug report for more details.

Fixes https://gitlab.com/kicad/code/kicad/issues/9150
This commit is contained in:
Jeff Young 2021-09-13 18:03:48 +01:00
parent 32e23d993e
commit b27b97809f
3 changed files with 8 additions and 5 deletions

View File

@ -62,6 +62,7 @@ DIALOG_CLEANUP_GRAPHICS_BASE::DIALOG_CLEANUP_GRAPHICS_BASE( wxWindow* parent, wx
// Connect Events
m_createRectanglesOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_GRAPHICS_BASE::OnCheckBox ), NULL, this );
m_deleteRedundantOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_GRAPHICS_BASE::OnCheckBox ), NULL, this );
m_changesDataView->Connect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_CLEANUP_GRAPHICS_BASE::OnSelectItem ), NULL, this );
m_changesDataView->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_CLEANUP_GRAPHICS_BASE::OnLeftDClickItem ), NULL, this );
}
@ -70,6 +71,7 @@ DIALOG_CLEANUP_GRAPHICS_BASE::~DIALOG_CLEANUP_GRAPHICS_BASE()
{
// Disconnect Events
m_createRectanglesOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_GRAPHICS_BASE::OnCheckBox ), NULL, this );
m_deleteRedundantOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_GRAPHICS_BASE::OnCheckBox ), NULL, this );
m_changesDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_CLEANUP_GRAPHICS_BASE::OnSelectItem ), NULL, this );
m_changesDataView->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_CLEANUP_GRAPHICS_BASE::OnLeftDClickItem ), NULL, this );

View File

@ -194,6 +194,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnCheckBox">OnCheckBox</event>
</object>
</object>
</object>

View File

@ -150,7 +150,7 @@ void GRAPHICS_CLEANER::cleanupSegments()
m_itemsList->push_back( item );
if( !m_dryRun )
m_commit.Removed( segment );
m_commit.Remove( segment );
continue;
}
@ -171,7 +171,7 @@ void GRAPHICS_CLEANER::cleanupSegments()
segment2->SetFlags( IS_DELETED );
if( !m_dryRun )
m_commit.Removed( segment2 );
m_commit.Remove( segment2 );
}
}
}
@ -204,7 +204,7 @@ void GRAPHICS_CLEANER::mergeRects()
{
PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( item );
if( !shape || shape->GetShape() != SHAPE_T::SEGMENT )
if( !shape || isNullShape( shape ) || shape->GetShape() != SHAPE_T::SEGMENT )
continue;
if( shape->GetStart().x == shape->GetEnd().x || shape->GetStart().y == shape->GetEnd().y )
@ -269,7 +269,7 @@ void GRAPHICS_CLEANER::mergeRects()
//
for( SIDE_CANDIDATE* candidate : ptMap[ top->end ] )
{
if( candidate != top && viable( candidate ) )
if( candidate != top && candidate != left && viable( candidate ) )
{
right = candidate;
break;
@ -278,7 +278,7 @@ void GRAPHICS_CLEANER::mergeRects()
for( SIDE_CANDIDATE* candidate : ptMap[ left->end ] )
{
if( candidate != left && viable( candidate ) )
if( candidate != top && candidate != left && viable( candidate ) )
{
bottom = candidate;
break;