From b05a40e72815650ab84fddb3632f48030207f9c3 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 23 Dec 2017 18:34:57 +0100 Subject: [PATCH] FOOTPRINT_WIZARD_FRAME: fis a serious issue when changing a parameter page when a parameter was currently edited Also Fixes: lp:1739881 --- pcbnew/footprint_wizard.cpp | 36 +++++++++++++++++++++++++------ pcbnew/footprint_wizard_frame.cpp | 26 +++++++++++----------- pcbnew/footprint_wizard_frame.h | 7 ++++-- 3 files changed, 47 insertions(+), 22 deletions(-) diff --git a/pcbnew/footprint_wizard.cpp b/pcbnew/footprint_wizard.cpp index 54a31e9ae0..2411f700e9 100644 --- a/pcbnew/footprint_wizard.cpp +++ b/pcbnew/footprint_wizard.cpp @@ -1,3 +1,28 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2012 Miguel Angel Ajo Pelayo, miguelangel@nbee.es + * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + /** * @file footprint_wizard.cpp */ @@ -7,7 +32,6 @@ #include #include #include -//#include <3d_viewer/eda_3d_viewer.h> #include #include @@ -222,18 +246,16 @@ void FOOTPRINT_WIZARD_FRAME::DefaultParameters( wxCommandEvent& event ) void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event ) { - int page = m_pageList->GetSelection(); - FOOTPRINT_WIZARD* footprintWizard = GetMyWizard(); if( !footprintWizard ) return; - if( page < 0 ) + if( m_parameterGridPage < 0 ) return; - wxArrayString prmValues = footprintWizard->GetParameterValues( page ); - wxArrayString ptList = footprintWizard->GetParameterTypes( page ); + wxArrayString prmValues = footprintWizard->GetParameterValues( m_parameterGridPage ); + wxArrayString ptList = footprintWizard->GetParameterTypes( m_parameterGridPage ); bool has_changed = false; int count = m_parameterGrid->GetNumberRows(); @@ -255,7 +277,7 @@ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event ) if( has_changed ) { - wxString res = footprintWizard->SetParameterValues( page, prmValues ); + wxString res = footprintWizard->SetParameterValues( m_parameterGridPage, prmValues ); if( !res.IsEmpty() ) wxMessageBox( res ); diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index 89c328bf69..6ec4b61064 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012-2015 Miguel Angel Ajo Pelayo - * Copyright (C) 2012-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2012-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008-2015 Wayne Stambaugh * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. * @@ -159,7 +159,8 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL ); - // Creates the The list of parameters for the current parameter page + // Creates the list of parameters for the current parameter page + m_parameterGridPage = -1; initParameterGrid(); ReCreatePageList(); @@ -347,19 +348,18 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList() if( footprintWizard == NULL ) return; - int page = m_pageList->GetSelection(); - - if( page<0 ) - return; - + m_parameterGridPage = m_pageList->GetSelection(); m_parameterGrid->ClearGrid(); + if( m_parameterGridPage < 0 ) // Should not happen + return; + // Get the list of names, values, types, hints and designators - wxArrayString designatorsList = footprintWizard->GetParameterDesignators( page ); - wxArrayString namesList = footprintWizard->GetParameterNames( page ); - wxArrayString valuesList = footprintWizard->GetParameterValues( page ); - wxArrayString typesList = footprintWizard->GetParameterTypes( page ); - wxArrayString hintsList = footprintWizard->GetParameterHints( page ); + wxArrayString designatorsList = footprintWizard->GetParameterDesignators( m_parameterGridPage ); + wxArrayString namesList = footprintWizard->GetParameterNames( m_parameterGridPage ); + wxArrayString valuesList = footprintWizard->GetParameterValues( m_parameterGridPage ); + wxArrayString typesList = footprintWizard->GetParameterTypes( m_parameterGridPage ); + wxArrayString hintsList = footprintWizard->GetParameterHints( m_parameterGridPage ); // Dimension the wxGrid if( m_parameterGrid->GetNumberRows() > 0 ) @@ -386,7 +386,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList() // Set the editor type of the - // Boolean parameters can be displayed using a checkbox + // Boolean parameters are displayed using a checkbox if( units == WIZARD_PARAM_UNITS_BOOL ) { wxGridCellBoolEditor *boolEditor = new wxGridCellBoolEditor; diff --git a/pcbnew/footprint_wizard_frame.h b/pcbnew/footprint_wizard_frame.h index 206e190c5a..9dcf3a3d5c 100644 --- a/pcbnew/footprint_wizard_frame.h +++ b/pcbnew/footprint_wizard_frame.h @@ -2,8 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012 Miguel Angel Ajo Pelayo, miguelangel@nbee.es - * Copyright (C) 2012 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -59,6 +59,9 @@ private: int m_pageListWidth; ///< width of the window wxGrid* m_parameterGrid; ///< The list of parameters int m_parameterGridWidth; ///< size of the grid + int m_parameterGridPage; ///< the page currently displayed by m_parameterGrid + ///< it is most of time the m_pageList selection, but can differ + ///< during transitions between pages. FOOTPRINT_WIZARD_MESSAGES* m_messagesFrame; protected: