Minor refinement to Import Settings from Board dialog.
Also some defensive code to protect against an ASAN stack buffer underflow. Fixes https://gitlab.com/kicad/code/kicad/issues/5660
This commit is contained in:
parent
0b108d61e7
commit
1039fb1bc5
|
@ -172,21 +172,31 @@ void DIALOG_BOARD_SETUP::OnAuxiliaryAction( wxCommandEvent& event )
|
|||
{
|
||||
BOARD* loadedBoard = m_frame->GetBoard();
|
||||
|
||||
// Check if "Import Settings" board has more layers than the current board.
|
||||
okToProceed = m_layers->compareCopperLayerCount( loadedBoard, otherBoard );
|
||||
// Check if "Import Settings" board has more layers than the current board.
|
||||
okToProceed = m_layers->CheckCopperLayerCount( loadedBoard, otherBoard );
|
||||
}
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
if( ioe.Problem() != wxT( "CANCEL" ) )
|
||||
// You wouldn't think boardFn.GetFullPath() would throw, but we get a stack buffer
|
||||
// underflow from ASAN. While it's probably an ASAN error, a second try/catch doesn't
|
||||
// cost us much.
|
||||
try
|
||||
{
|
||||
wxString msg =
|
||||
wxString::Format( _( "Error loading board file:\n%s" ), boardFn.GetFullPath() );
|
||||
DisplayErrorMessage( this, msg, ioe.What() );
|
||||
}
|
||||
if( ioe.Problem() != wxT( "CANCEL" ) )
|
||||
{
|
||||
wxString msg = wxString::Format( _( "Error loading board file:\n%s" ),
|
||||
boardFn.GetFullPath() );
|
||||
DisplayErrorMessage( this, msg, ioe.What() );
|
||||
}
|
||||
|
||||
if( otherPrj != &m_frame->Prj() )
|
||||
m_frame->GetSettingsManager()->UnloadProject( otherPrj, false );
|
||||
if( otherPrj != &m_frame->Prj() )
|
||||
m_frame->GetSettingsManager()->UnloadProject( otherPrj, false );
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
// That was already our best-efforts
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -15,64 +15,79 @@ DIALOG_IMPORT_SETTINGS_BASE::DIALOG_IMPORT_SETTINGS_BASE( wxWindow* parent, wxWi
|
|||
|
||||
m_MainSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxBoxSizer* bupperSizer;
|
||||
bupperSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
wxBoxSizer* bUpperSizer;
|
||||
bUpperSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxStaticText* importFromLabel;
|
||||
importFromLabel = new wxStaticText( this, wxID_ANY, _("Import from:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
importFromLabel->Wrap( -1 );
|
||||
bupperSizer->Add( importFromLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
bUpperSizer->Add( importFromLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
m_filePathCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_filePathCtrl->SetToolTip( _("Target directory for plot files. Can be absolute or relative to the board file location.") );
|
||||
m_filePathCtrl->SetMinSize( wxSize( 300,-1 ) );
|
||||
|
||||
bupperSizer->Add( m_filePathCtrl, 1, wxEXPAND|wxTOP|wxBOTTOM, 5 );
|
||||
bUpperSizer->Add( m_filePathCtrl, 1, wxEXPAND|wxTOP|wxBOTTOM, 5 );
|
||||
|
||||
m_browseButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
|
||||
m_browseButton->SetMinSize( wxSize( 29,29 ) );
|
||||
|
||||
bupperSizer->Add( m_browseButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
||||
bUpperSizer->Add( m_browseButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
||||
|
||||
|
||||
m_MainSizer->Add( bupperSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
m_MainSizer->Add( bUpperSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
wxBoxSizer* bmiddleSizer;
|
||||
bmiddleSizer = new wxBoxSizer( wxVERTICAL );
|
||||
wxBoxSizer* bMiddleSizer;
|
||||
bMiddleSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxBoxSizer* bLeftCol;
|
||||
bLeftCol = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxStaticText* importLabel;
|
||||
importLabel = new wxStaticText( this, wxID_ANY, _("Import:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
importLabel->Wrap( -1 );
|
||||
bmiddleSizer->Add( importLabel, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
|
||||
bLeftCol->Add( importLabel, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
|
||||
|
||||
m_LayersOpt = new wxCheckBox( this, wxID_ANY, _("Layers setup"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bmiddleSizer->Add( m_LayersOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
bLeftCol->Add( m_LayersOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_TextAndGraphicsOpt = new wxCheckBox( this, wxID_ANY, _("Text and graphics default properties"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bmiddleSizer->Add( m_TextAndGraphicsOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
bLeftCol->Add( m_TextAndGraphicsOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_ConstraintsOpt = new wxCheckBox( this, wxID_ANY, _("Design rules"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bmiddleSizer->Add( m_ConstraintsOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
bLeftCol->Add( m_ConstraintsOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_TracksAndViasOpt = new wxCheckBox( this, wxID_ANY, _("Predefined track and via dimensions"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bmiddleSizer->Add( m_TracksAndViasOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
bLeftCol->Add( m_TracksAndViasOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_MaskAndPasteOpt = new wxCheckBox( this, wxID_ANY, _("Solder mask/paste defaults"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bmiddleSizer->Add( m_MaskAndPasteOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
bLeftCol->Add( m_MaskAndPasteOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_SeveritiesOpt = new wxCheckBox( this, wxID_ANY, _("Violation severities"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bmiddleSizer->Add( m_SeveritiesOpt, 0, wxRIGHT|wxLEFT, 5 );
|
||||
bLeftCol->Add( m_SeveritiesOpt, 0, wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_NetclassesOpt = new wxCheckBox( this, wxID_ANY, _("Net classes"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bmiddleSizer->Add( m_NetclassesOpt, 0, wxALL, 5 );
|
||||
bLeftCol->Add( m_NetclassesOpt, 0, wxALL, 5 );
|
||||
|
||||
|
||||
m_MainSizer->Add( bmiddleSizer, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 );
|
||||
bMiddleSizer->Add( bLeftCol, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 );
|
||||
|
||||
m_buttonsSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
wxBoxSizer* bRightCol;
|
||||
bRightCol = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_selectAllButton = new wxButton( this, wxID_ANY, _("Select All"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_buttonsSizer->Add( m_selectAllButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 10 );
|
||||
bRightCol->Add( m_selectAllButton, 1, wxALIGN_CENTER_VERTICAL|wxALL|wxALIGN_RIGHT, 10 );
|
||||
|
||||
|
||||
bMiddleSizer->Add( bRightCol, 1, wxEXPAND|wxALL, 20 );
|
||||
|
||||
|
||||
m_MainSizer->Add( bMiddleSizer, 1, wxEXPAND|wxBOTTOM, 5 );
|
||||
|
||||
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
|
||||
m_MainSizer->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_buttonsSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_sdbSizer1 = new wxStdDialogButtonSizer();
|
||||
m_sdbSizer1OK = new wxButton( this, wxID_OK );
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -25,6 +25,7 @@
|
|||
#include <wx/button.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/statline.h>
|
||||
#include <wx/dialog.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -40,8 +41,9 @@ class DIALOG_IMPORT_SETTINGS_BASE : public DIALOG_SHIM
|
|||
wxBoxSizer* m_MainSizer;
|
||||
wxTextCtrl* m_filePathCtrl;
|
||||
wxBitmapButton* m_browseButton;
|
||||
wxBoxSizer* m_buttonsSizer;
|
||||
wxButton* m_selectAllButton;
|
||||
wxStaticLine* m_staticline1;
|
||||
wxBoxSizer* m_buttonsSizer;
|
||||
wxStdDialogButtonSizer* m_sdbSizer1;
|
||||
wxButton* m_sdbSizer1OK;
|
||||
wxButton* m_sdbSizer1Cancel;
|
||||
|
|
|
@ -749,12 +749,14 @@ void PANEL_SETUP_LAYERS::ImportSettingsFrom( BOARD* aBoard )
|
|||
}
|
||||
|
||||
|
||||
bool PANEL_SETUP_LAYERS::compareCopperLayerCount( BOARD* aWorkingBoard, BOARD* aImportedBoard )
|
||||
bool PANEL_SETUP_LAYERS::CheckCopperLayerCount( BOARD* aWorkingBoard, BOARD* aImportedBoard )
|
||||
{
|
||||
/* This function warns users if they are going to delete inner copper layers because
|
||||
they're importing settings from a board with less copper layers than the board
|
||||
already loaded. We want to return "true" as default on the assumption no layer will
|
||||
actually be deleted. */
|
||||
/*
|
||||
* This function warns users if they are going to delete inner copper layers because
|
||||
* they're importing settings from a board with less copper layers than the board
|
||||
* already loaded. We want to return "true" as default on the assumption no layer will
|
||||
* actually be deleted.
|
||||
*/
|
||||
bool okToDeleteCopperLayers = true;
|
||||
|
||||
// Get the number of copper layers in the loaded board and the "import settings" board
|
||||
|
|
|
@ -70,7 +70,7 @@ public:
|
|||
*
|
||||
* @return bool - Approval to delete inner copper if needed
|
||||
*/
|
||||
bool compareCopperLayerCount( BOARD* aWorkingBoard, BOARD* aImportedBoard );
|
||||
bool CheckCopperLayerCount( BOARD* aWorkingBoard, BOARD* aImportedBoard );
|
||||
|
||||
///> @return the selected layer mask within the UI checkboxes
|
||||
LSET GetUILayerMask();
|
||||
|
|
Loading…
Reference in New Issue