Cvpcb: Bug fix: Select previous free component crashes Cvpcb when no previous free component found, and both Select next and previous free component where not working very well.

This commit is contained in:
jean-pierre charras 2013-06-09 18:36:54 +02:00
parent a287f89304
commit 92ac2ac47e
2 changed files with 35 additions and 44 deletions

View File

@ -2,40 +2,42 @@ Contribute to KiCad (under Linux)
-------------------- --------------------
1) make sure you have all the dependencies of KiCad: 1) make sure you have all the dependencies of KiCad:
sudo apt-get install debhelper dpatch libx11-dev sudo apt-get install debhelper dpatch libx11-dev
sudo apt-get install libglu1-mesa-dev libgl1-mesa-dev mesa-common-dev sudo apt-get install libglu1-mesa-dev libgl1-mesa-dev mesa-common-dev
sudo apt-get install libwxbase2.8-dev libwxgtk2.8-dev libboost-dev fakeroot sudo apt-get install libwxbase2.8-dev libwxgtk2.8-dev libboost-dev fakeroot
sudo apt-get install cmake bzr sudo apt-get install cmake bzr
sudo apt-get install cmake bzr bzrtools
2) initialize Bazaar: 2) initialize Bazaar:
bzr whoami "John Doe <john.doe@gmail.com>" bzr whoami "John Doe <john.doe@gmail.com>"
3) get LATEST KiCad source tree and name it, for instance, "kicad_john": 3) get LATEST KiCad source tree and name it, for instance, "kicad_john":
cd ~/ cd ~/
bzr branch lp:kicad kicad_john bzr branch lp:kicad kicad_john
4) create a copy of this folder and zip it away (just in case). 4) Read coding_style_policy.pdt, in <kicad_sources>/Documentation,
and other docs.
5) Modify/add source code. 5) Modify/add source code.
cd kicad_john cd kicad_john
gedit ....... gedit .......
6) Compile: 6) Compile:
cd kicad_john cd kicad_john
mkdir build; cd build mkdir build; cd build
cmake ../ -DKICAD_TESTING_VERSION=ON -DCMAKE_BUILD_TYPE=Debug cmake ../ -DKICAD_TESTING_VERSION=ON -DCMAKE_BUILD_TYPE=Debug
to build a debug version to build a debug version
or or
cmake ../ -DKICAD_TESTING_VERSION=ON -DCMAKE_BUILD_TYPE=Release cmake ../ -DKICAD_TESTING_VERSION=ON -DCMAKE_BUILD_TYPE=Release
to build a release version to build a release version
make -j 4 # this is for a 4 core machine make
7) Repeat step 5 and 6 until satisfied. 7) Repeat step 5 and 6 until satisfied.
8) Create a patch: 8) Create a patch:
in kicad_john: in kicad_john:
if some files are added: bzr add [FILE...] if some files are added: bzr add [FILE...]
bzr diff > my_changes.patch bzr diff > my_changes.patch
9) Send the patch file "my_changes.patch" to the KiCad developers mailing list. 9) Send the patch file "my_changes.patch" to the KiCad developers mailing list.
in the subject of the e-mail include the keyword "[PATCH]". in the subject of the e-mail include the keyword "[PATCH]".

View File

@ -332,60 +332,50 @@ void CVPCB_MAINFRAME::ChangeFocus( bool aMoveRight )
void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event ) void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event )
{ {
int ii = 0;
int selection;
if( m_netlist.IsEmpty() ) if( m_netlist.IsEmpty() )
return; return;
selection = m_ListCmp->GetSelection(); long selection = m_ListCmp->GetFirstSelected();
if( selection < 0 ) if( selection < 0 )
selection = 0; selection = -1; // We will start to 0 for the first search , if no item selected
for( unsigned jj = 0; jj < m_netlist.GetCount(); jj++ ) for( unsigned jj = selection+1; jj < m_netlist.GetCount(); jj++ )
{ {
if( m_netlist.GetComponent( jj )->GetFootprintName().IsEmpty() && ii > selection ) if( m_netlist.GetComponent( jj )->GetFootprintName().IsEmpty() )
{ {
m_ListCmp->SetSelection( ii ); m_ListCmp->SetSelection( wxNOT_FOUND, false ); // Remove all selections
m_ListCmp->SetSelection( jj );
SendMessageToEESCHEMA(); SendMessageToEESCHEMA();
return; return;
} }
ii++;
} }
m_ListCmp->SetSelection( selection );
} }
void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event ) void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event )
{ {
int ii;
int selection;
if( m_netlist.IsEmpty() ) if( m_netlist.IsEmpty() )
return; return;
ii = m_ListCmp->GetCount() - 1; int selection = m_ListCmp->GetFirstSelected();
selection = m_ListCmp->GetSelection();
if( selection < 0 ) if( selection < 0 )
selection = m_ListCmp->GetCount() - 1; selection = m_ListCmp->GetCount();
else
while( m_ListCmp->GetNextSelected( selection ) >= 0 )
selection = m_ListCmp->GetNextSelected( selection );
for( unsigned kk = m_netlist.GetCount() - 1; kk >= 0; kk-- ) for( int kk = selection-1; kk >= 0; kk-- )
{ {
if( m_netlist.GetComponent( kk )->GetFootprintName().IsEmpty() && ii < selection ) if( m_netlist.GetComponent( kk )->GetFootprintName().IsEmpty() )
{ {
m_ListCmp->SetSelection( ii ); m_ListCmp->SetSelection( wxNOT_FOUND, false ); // Remove all selections
m_ListCmp->SetSelection( kk );
SendMessageToEESCHEMA(); SendMessageToEESCHEMA();
return; return;
} }
ii--;
} }
m_ListCmp->SetSelection( selection );
} }
@ -618,9 +608,8 @@ void CVPCB_MAINFRAME::DisplayStatus()
{ {
wxString footprintName = m_FootprintList->GetSelectedFootprint(); wxString footprintName = m_FootprintList->GetSelectedFootprint();
FOOTPRINT_INFO* module = m_footprints.GetModuleInfo( footprintName ); FOOTPRINT_INFO* module = m_footprints.GetModuleInfo( footprintName );
wxASSERT( module );
if( module ) if( module ) // can be NULL if no netlist loaded
{ {
msg = _( "Description: " ) + module->m_Doc; msg = _( "Description: " ) + module->m_Doc;
SetStatusText( msg, 0 ); SetStatusText( msg, 0 );