Pcbnew: fix Bug #1148785 (pcbnew crashes when using only one layer in autorouter ) , and a minor bug in dialog cleanup.
This commit is contained in:
parent
c1fbc8ef8b
commit
46f106b6cd
|
@ -410,7 +410,9 @@ void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color, int op_
|
||||||
|
|
||||||
for( ; dx <= lim; )
|
for( ; dx <= lim; )
|
||||||
{
|
{
|
||||||
if( ( dx >= 0 ) && ( dy >= 0 ) && ( dx < RoutingMatrix.m_Ncols ) && ( dy < RoutingMatrix.m_Nrows ) )
|
if( ( dx >= 0 ) && ( dy >= 0 ) &&
|
||||||
|
( dx < RoutingMatrix.m_Ncols ) &&
|
||||||
|
( dy < RoutingMatrix.m_Nrows ) )
|
||||||
{
|
{
|
||||||
OP_CELL( layer, dy, dx );
|
OP_CELL( layer, dy, dx );
|
||||||
}
|
}
|
||||||
|
@ -475,7 +477,8 @@ void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1,
|
||||||
if( ( aLayerMask & GetLayerMask( Route_Layer_BOTTOM ) ) )
|
if( ( aLayerMask & GetLayerMask( Route_Layer_BOTTOM ) ) )
|
||||||
trace = 1; // Trace on BOTTOM
|
trace = 1; // Trace on BOTTOM
|
||||||
|
|
||||||
if( ( aLayerMask & GetLayerMask( Route_Layer_TOP ) ) && RoutingMatrix.m_RoutingLayersCount > 1 )
|
if( ( aLayerMask & GetLayerMask( Route_Layer_TOP ) ) &&
|
||||||
|
RoutingMatrix.m_RoutingLayersCount > 1 )
|
||||||
trace |= 2; // Trace on TOP
|
trace |= 2; // Trace on TOP
|
||||||
|
|
||||||
if( trace == 0 )
|
if( trace == 0 )
|
||||||
|
|
|
@ -100,45 +100,47 @@ bool MATRIX_ROUTING_HEAD::ComputeMatrixSize( BOARD* aPcb, bool aUseBoardEdgesOnl
|
||||||
|
|
||||||
int MATRIX_ROUTING_HEAD::InitRoutingMatrix()
|
int MATRIX_ROUTING_HEAD::InitRoutingMatrix()
|
||||||
{
|
{
|
||||||
int ii, kk;
|
|
||||||
|
|
||||||
if( m_Nrows <= 0 || m_Ncols <= 0 )
|
if( m_Nrows <= 0 || m_Ncols <= 0 )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
m_InitMatrixDone = true; // we have been called
|
m_InitMatrixDone = true; // we have been called
|
||||||
|
|
||||||
// give a small margin for memory allocation:
|
// give a small margin for memory allocation:
|
||||||
ii = (RoutingMatrix.m_Nrows + 1) * (RoutingMatrix.m_Ncols + 1);
|
int ii = (RoutingMatrix.m_Nrows + 1) * (RoutingMatrix.m_Ncols + 1);
|
||||||
|
|
||||||
for( kk = 0; kk < m_RoutingLayersCount; kk++ )
|
int side = BOTTOM;
|
||||||
|
for( int jj = 0; jj < m_RoutingLayersCount; jj++ ) // m_RoutingLayersCount = 1 or 2
|
||||||
{
|
{
|
||||||
m_BoardSide[kk] = NULL;
|
m_BoardSide[side] = NULL;
|
||||||
m_DistSide[kk] = NULL;
|
m_DistSide[side] = NULL;
|
||||||
m_DirSide[kk] = NULL;
|
m_DirSide[side] = NULL;
|
||||||
|
|
||||||
/* allocate matrix & initialize everything to empty */
|
/* allocate matrix & initialize everything to empty */
|
||||||
m_BoardSide[kk] = (MATRIX_CELL*) operator new( ii * sizeof(MATRIX_CELL) );
|
m_BoardSide[side] = (MATRIX_CELL*) operator new( ii * sizeof(MATRIX_CELL) );
|
||||||
memset( m_BoardSide[kk], 0, ii * sizeof(MATRIX_CELL) );
|
memset( m_BoardSide[side], 0, ii * sizeof(MATRIX_CELL) );
|
||||||
|
|
||||||
if( m_BoardSide[kk] == NULL )
|
if( m_BoardSide[side] == NULL )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// allocate Distances
|
// allocate Distances
|
||||||
m_DistSide[kk] = (DIST_CELL*) operator new( ii * sizeof(DIST_CELL) );
|
m_DistSide[side] = (DIST_CELL*) operator new( ii * sizeof(DIST_CELL) );
|
||||||
memset( m_DistSide[kk], 0, ii * sizeof(DIST_CELL) );
|
memset( m_DistSide[side], 0, ii * sizeof(DIST_CELL) );
|
||||||
|
|
||||||
if( m_DistSide[kk] == NULL )
|
if( m_DistSide[side] == NULL )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// allocate Dir (chars)
|
// allocate Dir (chars)
|
||||||
m_DirSide[kk] = (char*) operator new( ii );
|
m_DirSide[side] = (char*) operator new( ii );
|
||||||
memset( m_DirSide[kk], 0, ii );
|
memset( m_DirSide[side], 0, ii );
|
||||||
|
|
||||||
if( m_DirSide[kk] == NULL )
|
if( m_DirSide[side] == NULL )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
side = TOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_MemSize = m_RouteCount * ii * ( sizeof(MATRIX_CELL) + sizeof(DIST_CELL) + sizeof(char) );
|
m_MemSize = m_RouteCount * ii * ( sizeof(MATRIX_CELL)
|
||||||
|
+ sizeof(DIST_CELL) + sizeof(char) );
|
||||||
|
|
||||||
return m_MemSize;
|
return m_MemSize;
|
||||||
}
|
}
|
||||||
|
|
|
@ -433,13 +433,16 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
|
||||||
|
|
||||||
/* clear direction flags */
|
/* clear direction flags */
|
||||||
i = RoutingMatrix.m_Nrows * RoutingMatrix.m_Ncols * sizeof(DIR_CELL);
|
i = RoutingMatrix.m_Nrows * RoutingMatrix.m_Ncols * sizeof(DIR_CELL);
|
||||||
memset( RoutingMatrix.m_DirSide[TOP], FROM_NOWHERE, i );
|
|
||||||
|
if( two_sides )
|
||||||
|
memset( RoutingMatrix.m_DirSide[TOP], FROM_NOWHERE, i );
|
||||||
memset( RoutingMatrix.m_DirSide[BOTTOM], FROM_NOWHERE, i );
|
memset( RoutingMatrix.m_DirSide[BOTTOM], FROM_NOWHERE, i );
|
||||||
|
|
||||||
lastopen = lastclos = lastmove = 0;
|
lastopen = lastclos = lastmove = 0;
|
||||||
|
|
||||||
/* Set tab_masque[side] for final test of routing. */
|
/* Set tab_masque[side] for final test of routing. */
|
||||||
tab_mask[TOP] = topLayerMask;
|
if( two_sides )
|
||||||
|
tab_mask[TOP] = topLayerMask;
|
||||||
tab_mask[BOTTOM] = bottomLayerMask;
|
tab_mask[BOTTOM] = bottomLayerMask;
|
||||||
|
|
||||||
/* Set active layers mask. */
|
/* Set active layers mask. */
|
||||||
|
@ -1170,11 +1173,11 @@ static void OrCell_Trace( BOARD* pcb, int col, int row,
|
||||||
g_CurrentTrackSegment->SetLayer( 0x0F );
|
g_CurrentTrackSegment->SetLayer( 0x0F );
|
||||||
|
|
||||||
g_CurrentTrackSegment->SetStart(wxPoint( pcb->GetBoundingBox().GetX() +
|
g_CurrentTrackSegment->SetStart(wxPoint( pcb->GetBoundingBox().GetX() +
|
||||||
( RoutingMatrix.m_GridRouting * row ),
|
( RoutingMatrix.m_GridRouting * row ),
|
||||||
pcb->GetBoundingBox().GetY() +
|
pcb->GetBoundingBox().GetY() +
|
||||||
( RoutingMatrix.m_GridRouting * col )));
|
( RoutingMatrix.m_GridRouting * col )));
|
||||||
g_CurrentTrackSegment->SetEnd( g_CurrentTrackSegment->GetStart() );
|
g_CurrentTrackSegment->SetEnd( g_CurrentTrackSegment->GetStart() );
|
||||||
|
|
||||||
g_CurrentTrackSegment->SetWidth( pcb->GetCurrentViaSize() );
|
g_CurrentTrackSegment->SetWidth( pcb->GetCurrentViaSize() );
|
||||||
g_CurrentTrackSegment->SetShape( pcb->GetDesignSettings().m_CurrentViaType );
|
g_CurrentTrackSegment->SetShape( pcb->GetDesignSettings().m_CurrentViaType );
|
||||||
|
|
||||||
|
|
|
@ -112,21 +112,22 @@ void PCB_EDIT_FRAME::Clean_Pcb( wxDC* DC )
|
||||||
{
|
{
|
||||||
DIALOG_CLEANING_OPTIONS dlg( this );
|
DIALOG_CLEANING_OPTIONS dlg( this );
|
||||||
|
|
||||||
if( dlg.ShowModal() == wxID_OK )
|
if( dlg.ShowModal() != wxID_OK )
|
||||||
|
return;
|
||||||
|
|
||||||
|
wxBusyCursor( dummy );
|
||||||
|
TRACKS_CLEANER cleaner( GetBoard() );
|
||||||
|
cleaner.SetdeleteUnconnectedTracksOpt( dlg.deleteUnconnectedSegm );
|
||||||
|
cleaner.SetMergeSegmentsOpt( dlg.mergeSegments );
|
||||||
|
cleaner.SetCleanViasOpt( dlg.cleanVias );
|
||||||
|
|
||||||
|
if( cleaner.CleanupBoard() )
|
||||||
{
|
{
|
||||||
wxBusyCursor( dummy );
|
// Clear undo and redo lists to avoid inconsistencies between lists
|
||||||
TRACKS_CLEANER cleaner( GetBoard() );
|
GetScreen()->ClearUndoRedoList();
|
||||||
cleaner.SetdeleteUnconnectedTracksOpt( dlg.deleteUnconnectedSegm );
|
SetCurItem( NULL );
|
||||||
cleaner.SetMergeSegmentsOpt( dlg.mergeSegments );
|
Compile_Ratsnest( NULL, true );
|
||||||
cleaner.SetCleanViasOpt( dlg.cleanVias );
|
OnModify();
|
||||||
if( cleaner.CleanupBoard() )
|
|
||||||
{
|
|
||||||
// Clear undo and redo lists to avoid inconsistencies between lists
|
|
||||||
GetScreen()->ClearUndoRedoList();
|
|
||||||
SetCurItem( NULL );
|
|
||||||
Compile_Ratsnest( NULL, true );
|
|
||||||
OnModify();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_canvas->Refresh( true );
|
m_canvas->Refresh( true );
|
||||||
|
|
|
@ -32,9 +32,9 @@
|
||||||
DIALOG_CLEANING_OPTIONS::DIALOG_CLEANING_OPTIONS( wxWindow* parent ):
|
DIALOG_CLEANING_OPTIONS::DIALOG_CLEANING_OPTIONS( wxWindow* parent ):
|
||||||
DIALOG_CLEANING_OPTIONS_BASE( parent )
|
DIALOG_CLEANING_OPTIONS_BASE( parent )
|
||||||
{
|
{
|
||||||
m_cleanViasOpt->SetValue( cleanVias );
|
m_cleanViasOpt->SetValue( m_cleanVias );
|
||||||
m_mergeSegmOpt->SetValue( mergeSegments );
|
m_mergeSegmOpt->SetValue( m_mergeSegments );
|
||||||
m_deleteUnconnectedOpt->SetValue( deleteUnconnectedSegm );
|
m_deleteUnconnectedOpt->SetValue( m_deleteUnconnectedSegm );
|
||||||
|
|
||||||
m_sdbSizerOK->SetDefault();
|
m_sdbSizerOK->SetDefault();
|
||||||
GetSizer()->SetSizeHints(this);
|
GetSizer()->SetSizeHints(this);
|
||||||
|
@ -42,7 +42,7 @@ DIALOG_CLEANING_OPTIONS::DIALOG_CLEANING_OPTIONS( wxWindow* parent ):
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static members of DIALOG_CLEANING_OPTIONS
|
// Static members of DIALOG_CLEANING_OPTIONS
|
||||||
bool DIALOG_CLEANING_OPTIONS::cleanVias = true;
|
bool DIALOG_CLEANING_OPTIONS::m_cleanVias = true;
|
||||||
bool DIALOG_CLEANING_OPTIONS::mergeSegments = true;
|
bool DIALOG_CLEANING_OPTIONS::m_mergeSegments = true;
|
||||||
bool DIALOG_CLEANING_OPTIONS::deleteUnconnectedSegm = true;
|
bool DIALOG_CLEANING_OPTIONS::m_deleteUnconnectedSegm = true;
|
||||||
|
|
||||||
|
|
|
@ -11,15 +11,16 @@
|
||||||
class DIALOG_CLEANING_OPTIONS: public DIALOG_CLEANING_OPTIONS_BASE
|
class DIALOG_CLEANING_OPTIONS: public DIALOG_CLEANING_OPTIONS_BASE
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static bool cleanVias;
|
static bool m_cleanVias;
|
||||||
static bool mergeSegments;
|
static bool m_mergeSegments;
|
||||||
static bool deleteUnconnectedSegm;
|
static bool m_deleteUnconnectedSegm;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DIALOG_CLEANING_OPTIONS( wxWindow* parent );
|
DIALOG_CLEANING_OPTIONS( wxWindow* parent );
|
||||||
|
|
||||||
~DIALOG_CLEANING_OPTIONS()
|
~DIALOG_CLEANING_OPTIONS()
|
||||||
{
|
{
|
||||||
|
GetOpts( );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -33,17 +34,11 @@ private:
|
||||||
EndModal( wxID_OK );
|
EndModal( wxID_OK );
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnCloseWindow( wxCloseEvent& event )
|
|
||||||
{
|
|
||||||
GetOpts( );
|
|
||||||
EndModal( wxID_CANCEL );
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetOpts( )
|
void GetOpts( )
|
||||||
{
|
{
|
||||||
cleanVias = m_cleanViasOpt->GetValue( );
|
m_cleanVias = m_cleanViasOpt->GetValue( );
|
||||||
mergeSegments = m_mergeSegmOpt->GetValue( );
|
m_mergeSegments = m_mergeSegmOpt->GetValue( );
|
||||||
deleteUnconnectedSegm = m_deleteUnconnectedOpt->GetValue( );
|
m_deleteUnconnectedSegm = m_deleteUnconnectedOpt->GetValue( );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,6 @@ DIALOG_CLEANING_OPTIONS_BASE::DIALOG_CLEANING_OPTIONS_BASE( wxWindow* parent, wx
|
||||||
this->Centre( wxBOTH );
|
this->Centre( wxBOTH );
|
||||||
|
|
||||||
// Connect Events
|
// Connect Events
|
||||||
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_CLEANING_OPTIONS_BASE::OnCloseWindow ) );
|
|
||||||
m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CLEANING_OPTIONS_BASE::OnCancelClick ), NULL, this );
|
m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CLEANING_OPTIONS_BASE::OnCancelClick ), NULL, this );
|
||||||
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CLEANING_OPTIONS_BASE::OnOKClick ), NULL, this );
|
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CLEANING_OPTIONS_BASE::OnOKClick ), NULL, this );
|
||||||
}
|
}
|
||||||
|
@ -64,7 +63,6 @@ DIALOG_CLEANING_OPTIONS_BASE::DIALOG_CLEANING_OPTIONS_BASE( wxWindow* parent, wx
|
||||||
DIALOG_CLEANING_OPTIONS_BASE::~DIALOG_CLEANING_OPTIONS_BASE()
|
DIALOG_CLEANING_OPTIONS_BASE::~DIALOG_CLEANING_OPTIONS_BASE()
|
||||||
{
|
{
|
||||||
// Disconnect Events
|
// Disconnect Events
|
||||||
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_CLEANING_OPTIONS_BASE::OnCloseWindow ) );
|
|
||||||
m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CLEANING_OPTIONS_BASE::OnCancelClick ), NULL, this );
|
m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CLEANING_OPTIONS_BASE::OnCancelClick ), NULL, this );
|
||||||
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CLEANING_OPTIONS_BASE::OnOKClick ), NULL, this );
|
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CLEANING_OPTIONS_BASE::OnOKClick ), NULL, this );
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
<event name="OnAuiPaneRestore"></event>
|
<event name="OnAuiPaneRestore"></event>
|
||||||
<event name="OnAuiRender"></event>
|
<event name="OnAuiRender"></event>
|
||||||
<event name="OnChar"></event>
|
<event name="OnChar"></event>
|
||||||
<event name="OnClose">OnCloseWindow</event>
|
<event name="OnClose"></event>
|
||||||
<event name="OnEnterWindow"></event>
|
<event name="OnEnterWindow"></event>
|
||||||
<event name="OnEraseBackground"></event>
|
<event name="OnEraseBackground"></event>
|
||||||
<event name="OnHibernate"></event>
|
<event name="OnHibernate"></event>
|
||||||
|
|
|
@ -45,7 +45,6 @@ class DIALOG_CLEANING_OPTIONS_BASE : public DIALOG_SHIM
|
||||||
wxButton* m_sdbSizerCancel;
|
wxButton* m_sdbSizerCancel;
|
||||||
|
|
||||||
// Virtual event handlers, overide them in your derived class
|
// Virtual event handlers, overide them in your derived class
|
||||||
virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); }
|
|
||||||
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue