Commit 6a3a1085 authored by dickelbeck's avatar dickelbeck

crashing bug fix

parent 9e9a8fcf
...@@ -5,6 +5,17 @@ Started 2007-June-11 ...@@ -5,6 +5,17 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2008-Mar-17 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+pcbnew
* Fixed a crashing bug which occured when you run the module editor, select
"Update module in current board" and then run the DRC checker after that.
* Changed to void CreateSortedPadListByXCoord( BOARD* aBoard, std::vector<D_PAD*>* aVector )
So caller can safely forget to delete the array of pad pointers and the vector's
destructor handles this automatically.
2008-Mar-14 UPDATE Dick Hollenbeck <dick@softplc.com> 2008-Mar-14 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
+eeschema +eeschema
......
...@@ -542,20 +542,15 @@ static int SortPadsByXCoord( const void* pt_ref, const void* pt_comp ) ...@@ -542,20 +542,15 @@ static int SortPadsByXCoord( const void* pt_ref, const void* pt_comp )
} }
/****************************************************/ /*****************************************************************************/
LISTE_PAD* CreateSortedPadListByXCoord( BOARD* pcb ) void CreateSortedPadListByXCoord( BOARD* aBoard, std::vector<D_PAD*>* aVector )
/****************************************************/ /*****************************************************************************/
/* Create a sorted list of pointers to pads.
* This list is sorted by X ccordinate value.
* The list must be freed by user
*/
{ {
LISTE_PAD* pad_list = (LISTE_PAD*) MyMalloc( pcb->m_NbPads * sizeof(D_PAD*) ); aVector->resize( aBoard->m_NbPads );
memcpy( &(*aVector)[0], aBoard->m_Pads, aBoard->m_NbPads * sizeof( D_PAD*) );
memcpy( pad_list, pcb->m_Pads, pcb->m_NbPads * sizeof( D_PAD*) ); qsort( &(*aVector)[0], aBoard->m_NbPads, sizeof( D_PAD*), SortPadsByXCoord );
qsort( pad_list, pcb->m_NbPads, sizeof( D_PAD*), SortPadsByXCoord );
return pad_list;
} }
...@@ -570,11 +565,11 @@ void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche ) ...@@ -570,11 +565,11 @@ void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche )
* We search a connection between a track segment and a pad: if found : this segment netcode is set to the pad netcode * We search a connection between a track segment and a pad: if found : this segment netcode is set to the pad netcode
*/ */
{ {
TRACK* pt_piste, TRACK* pt_piste;
* pt_next; TRACK* pt_next;
int a_color; int a_color;
char new_passe_request = 1, flag; char new_passe_request = 1, flag;
LISTE_PAD* pt_mem; std::vector<D_PAD*> sortedPads;
BOARD_ITEM* PtStruct; BOARD_ITEM* PtStruct;
int masque_layer; int masque_layer;
wxString msg; wxString msg;
...@@ -595,7 +590,7 @@ void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche ) ...@@ -595,7 +590,7 @@ void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche )
/**************************************************************/ /**************************************************************/
/* Pass 1: search the connections between track ends and pads */ /* Pass 1: search the connections between track ends and pads */
/**************************************************************/ /**************************************************************/
pt_mem = CreateSortedPadListByXCoord( m_Pcb ); CreateSortedPadListByXCoord( m_Pcb, &sortedPads );
if( affiche ) if( affiche )
Affiche_1_Parametre( this, -1, wxEmptyString, wxT( "Conn Pads" ), a_color ); Affiche_1_Parametre( this, -1, wxEmptyString, wxT( "Conn Pads" ), a_color );
...@@ -619,7 +614,7 @@ void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche ) ...@@ -619,7 +614,7 @@ void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche )
/* Search for a pad on the segment starting point */ /* Search for a pad on the segment starting point */
pt_piste->start = SuperFast_Locate_Pad_Connecte( m_Pcb, pt_piste->start = SuperFast_Locate_Pad_Connecte( m_Pcb,
pt_mem, &sortedPads[0],
pt_piste->m_Start.x, pt_piste->m_Start.x,
pt_piste->m_Start.y, pt_piste->m_Start.y,
masque_layer ); masque_layer );
...@@ -631,7 +626,7 @@ void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche ) ...@@ -631,7 +626,7 @@ void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche )
/* Search for a pad on the segment ending point */ /* Search for a pad on the segment ending point */
pt_piste->end = SuperFast_Locate_Pad_Connecte( m_Pcb, pt_piste->end = SuperFast_Locate_Pad_Connecte( m_Pcb,
pt_mem, &sortedPads[0],
pt_piste->m_End.x, pt_piste->m_End.x,
pt_piste->m_End.y, pt_piste->m_End.y,
masque_layer ); masque_layer );
...@@ -643,7 +638,6 @@ void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche ) ...@@ -643,7 +638,6 @@ void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche )
} }
} }
MyFree( pt_mem );
/*****************************************************/ /*****************************************************/
/* Pass 2: search the connections between track ends */ /* Pass 2: search the connections between track ends */
......
...@@ -635,6 +635,11 @@ void DrcDialog::OnStartdrcClick( wxCommandEvent& event ) ...@@ -635,6 +635,11 @@ void DrcDialog::OnStartdrcClick( wxCommandEvent& event )
wxBeginBusyCursor(); wxBeginBusyCursor();
// running the module editor and selecting "Update module in current board"
// causes the list to become obsolete because of the new pads from the
// revised module.
m_Parent->build_liste_pads();
// run all the tests, with no UI at this time. // run all the tests, with no UI at this time.
m_tester->RunTests(); m_tester->RunTests();
......
...@@ -197,7 +197,7 @@ void DRC::RunTests() ...@@ -197,7 +197,7 @@ void DRC::RunTests()
testTracks(); testTracks();
// test zone clearances to other zones, pads, tracks, and vias // test zone clearances to other zones, pads, tracks, and vias
testZones(m_doZonesTest); testZones( m_doZonesTest );
// find and gather unconnected pads. // find and gather unconnected pads.
if( m_doUnconnectedTest ) if( m_doUnconnectedTest )
...@@ -251,33 +251,35 @@ void DRC::testTracks() ...@@ -251,33 +251,35 @@ void DRC::testTracks()
void DRC::testPad2Pad() void DRC::testPad2Pad()
{ {
LISTE_PAD* pad_list_start = CreateSortedPadListByXCoord( m_pcb ); std::vector<D_PAD*> sortedPads;
LISTE_PAD* pad_list_limit = &pad_list_start[m_pcb->m_NbPads];
LISTE_PAD* ppad; CreateSortedPadListByXCoord( m_pcb, &sortedPads );
// find the max size of the pads (used to stop the test) // find the max size of the pads (used to stop the test)
int max_size = 0; int max_size = 0;
for( ppad = pad_list_start; ppad<pad_list_limit; ppad++ )
for( unsigned i=0; i<sortedPads.size(); ++i )
{ {
D_PAD* pad = *ppad; D_PAD* pad = sortedPads[i];
if( pad->m_Rayon > max_size ) if( pad->m_Rayon > max_size )
max_size = pad->m_Rayon; max_size = pad->m_Rayon;
} }
// Test the pads // Test the pads
for( ppad = pad_list_start; ppad<pad_list_limit; ppad++ ) D_PAD** listEnd = &sortedPads[ sortedPads.size() ];
for( unsigned i=0; i<sortedPads.size(); ++i )
{ {
D_PAD* pad = *ppad; D_PAD* pad = sortedPads[i];
if( !doPadToPadsDrc( pad, ppad, pad_list_limit, max_size ) ) if( !doPadToPadsDrc( pad, &sortedPads[i], listEnd, max_size ) )
{ {
wxASSERT( m_currentMarker ); wxASSERT( m_currentMarker );
m_pcb->Add( m_currentMarker ); m_pcb->Add( m_currentMarker );
m_currentMarker = 0; m_currentMarker = 0;
} }
} }
free( pad_list_start );
} }
......
...@@ -5,10 +5,26 @@ ...@@ -5,10 +5,26 @@
#ifndef PROTO_H #ifndef PROTO_H
#define PROTO_H #define PROTO_H
#include <vector>
/***************/ /***************/
/* PAD_CONNECT.CPP */ /* PAD_CONNECT.CPP */
/***************/ /***************/
LISTE_PAD* CreateSortedPadListByXCoord( BOARD* pcb );
class D_PAD;
/**
* Function CreateSortedPadListByXCoord
* first empties then fills the vector with all pads and sorts them by
* increasing x coordinate. The vector only holds pointers to the pads and
* those pointers are only references to pads which are owned by the BOARD
* through other links.
* @param aBoard Which board to gather pads from.
* @param aVector Where to put the pad pointers.
*/
void CreateSortedPadListByXCoord( BOARD* aBoard, std::vector<D_PAD*>* aVector );
/* Create a sorted list of pointers to pads. /* Create a sorted list of pointers to pads.
* This list is sorted by X ccordinate value. * This list is sorted by X ccordinate value.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment