From 92ac2ac47e2b1b386f17829232c5f6b4ced7c46d Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 9 Jun 2013 18:36:54 +0200 Subject: [PATCH] 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. --- HOW_TO_CONTRIBUTE.txt | 36 +++++++++++++++++++----------------- cvpcb/cvframe.cpp | 43 ++++++++++++++++--------------------------- 2 files changed, 35 insertions(+), 44 deletions(-) diff --git a/HOW_TO_CONTRIBUTE.txt b/HOW_TO_CONTRIBUTE.txt index 6175aa05d9..7cad15b06e 100644 --- a/HOW_TO_CONTRIBUTE.txt +++ b/HOW_TO_CONTRIBUTE.txt @@ -2,40 +2,42 @@ Contribute to KiCad (under Linux) -------------------- 1) make sure you have all the dependencies of KiCad: - 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 libwxbase2.8-dev libwxgtk2.8-dev libboost-dev fakeroot - sudo apt-get install cmake bzr + 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 libwxbase2.8-dev libwxgtk2.8-dev libboost-dev fakeroot + sudo apt-get install cmake bzr + sudo apt-get install cmake bzr bzrtools 2) initialize Bazaar: - bzr whoami "John Doe " + bzr whoami "John Doe " 3) get LATEST KiCad source tree and name it, for instance, "kicad_john": - cd ~/ - bzr branch lp:kicad kicad_john + cd ~/ + 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 /Documentation, + and other docs. 5) Modify/add source code. - cd kicad_john - gedit ....... + cd kicad_john + gedit ....... 6) Compile: - cd kicad_john - mkdir build; cd build - cmake ../ -DKICAD_TESTING_VERSION=ON -DCMAKE_BUILD_TYPE=Debug + cd kicad_john + mkdir build; cd build + cmake ../ -DKICAD_TESTING_VERSION=ON -DCMAKE_BUILD_TYPE=Debug to build a debug version or - cmake ../ -DKICAD_TESTING_VERSION=ON -DCMAKE_BUILD_TYPE=Release + cmake ../ -DKICAD_TESTING_VERSION=ON -DCMAKE_BUILD_TYPE=Release to build a release version - make -j 4 # this is for a 4 core machine + make 7) Repeat step 5 and 6 until satisfied. 8) Create a patch: - in kicad_john: + in kicad_john: 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. in the subject of the e-mail include the keyword "[PATCH]". diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index d25fde6d09..750e2d9924 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -332,60 +332,50 @@ void CVPCB_MAINFRAME::ChangeFocus( bool aMoveRight ) void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event ) { - int ii = 0; - int selection; - if( m_netlist.IsEmpty() ) return; - selection = m_ListCmp->GetSelection(); + long selection = m_ListCmp->GetFirstSelected(); 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(); return; } - - ii++; } - - m_ListCmp->SetSelection( selection ); } void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event ) { - int ii; - int selection; - if( m_netlist.IsEmpty() ) return; - ii = m_ListCmp->GetCount() - 1; - selection = m_ListCmp->GetSelection(); + int selection = m_ListCmp->GetFirstSelected(); 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(); return; } - - ii--; } - - m_ListCmp->SetSelection( selection ); } @@ -618,9 +608,8 @@ void CVPCB_MAINFRAME::DisplayStatus() { wxString footprintName = m_FootprintList->GetSelectedFootprint(); 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; SetStatusText( msg, 0 );