Fix a few Coverity warnings.

It also fix:

Fixes #4082
https://gitlab.com/kicad/code/kicad/issues/4082
This commit is contained in:
jean-pierre charras 2020-03-29 18:42:24 +02:00
parent 259d7a47d4
commit 9d2712a824
10 changed files with 43 additions and 19 deletions

View File

@ -63,6 +63,7 @@ PLOTTER::PLOTTER( )
m_mirrorIsHorizontal = true;
m_yaxisReversed = false;
outputFile = 0;
m_colors = nullptr;
colorMode = false; // Starts as a BW plot
negativeMode = false;
// Temporary init to avoid not initialized vars, will be set later

View File

@ -143,7 +143,6 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const
Layout();
EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
wxASSERT( cfg );
if( cfg )
{
@ -212,6 +211,8 @@ DIALOG_CHOOSE_COMPONENT::~DIALOG_CHOOSE_COMPONENT()
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
wxCHECK( cfg, /*void*/ );
cfg->m_SymChooserPanel.width = GetSize().x;
cfg->m_SymChooserPanel.height = GetSize().y;
@ -263,12 +264,12 @@ wxPanel* DIALOG_CHOOSE_COMPONENT::ConstructRightPanel( wxWindow* aParent )
m_keepSymbol = new wxCheckBox( panel, 1000, _("Multi-Symbol Placement"), wxDefaultPosition,
wxDefaultSize, wxALIGN_RIGHT );
m_keepSymbol->SetValue( cfg->m_SymChooserPanel.keep_symbol );
m_keepSymbol->SetValue( cfg ? cfg->m_SymChooserPanel.keep_symbol : true );
m_keepSymbol->SetToolTip( _( "Place multiple copies of the symbol." ) );
m_useUnits = new wxCheckBox( panel, 1000, _("Place all units"), wxDefaultPosition,
wxDefaultSize, wxALIGN_RIGHT );
m_useUnits->SetValue( cfg->m_SymChooserPanel.place_all_units );
m_useUnits->SetValue( cfg ? cfg->m_SymChooserPanel.place_all_units : true );
m_useUnits->SetToolTip( _( "Sequentially place all units of the symbol." ) );
auto fgSizer = new wxFlexGridSizer( 0, 2, 0, 1 );

View File

@ -78,7 +78,10 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT
// Show/hide columns according to user's preference
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
m_shownColumns = cfg->m_Appearance.edit_component_visible_columns;
if( cfg )
m_shownColumns = cfg->m_Appearance.edit_component_visible_columns;
m_grid->ShowHideColumns( m_shownColumns );
wxToolTip::Enable( true );
@ -110,7 +113,9 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC()
{
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
cfg->m_Appearance.edit_component_visible_columns = m_grid->GetShownColumns();
if( cfg )
cfg->m_Appearance.edit_component_visible_columns = m_grid->GetShownColumns();
// Prevents crash bug in wxGrid's d'tor
m_grid->DestroyTable( m_fields );

View File

@ -932,7 +932,8 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::LoadFieldNames()
// Force References to always be shown
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
wxASSERT( cfg );
wxCHECK( cfg, /*void*/ );
cfg->m_FieldEditorPanel.fields_show["Reference"] = true;
// *DO NOT* use translated mandatory field names:

View File

@ -293,7 +293,10 @@ void DIALOG_RESCUE_EACH::OnNeverShowClick( wxCommandEvent& aEvent )
if( resp == wxID_YES )
{
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
cfg->m_RescueNeverShow = true;
if( cfg )
cfg->m_RescueNeverShow = true;
m_Rescuer->m_chosen_candidates.clear();
Close();
}

View File

@ -224,15 +224,18 @@ void LIB_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
auto cfg = dynamic_cast<LIBEDIT_SETTINGS*>( aCfg );
wxASSERT( cfg );
SetDefaultLineThickness( Mils2iu( cfg->m_Defaults.line_width ) );
SetDefaultPinLength( Mils2iu( cfg->m_Defaults.pin_length ) );
m_textPinNameDefaultSize = Mils2iu( cfg->m_Defaults.pin_name_size );
m_textPinNumDefaultSize = Mils2iu( cfg->m_Defaults.pin_num_size );
SetRepeatDeltaLabel( cfg->m_Repeat.label_delta );
SetRepeatPinStep( Mils2iu( cfg->m_Repeat.pin_step ) );
SetRepeatStep( wxPoint( cfg->m_Repeat.x_step, cfg->m_Repeat.y_step ) );
m_showPinElectricalTypeName = cfg->m_ShowPinElectricalType;
m_defaultLibWidth = cfg->m_LibWidth;
if( cfg )
{
SetDefaultLineThickness( Mils2iu( cfg->m_Defaults.line_width ) );
SetDefaultPinLength( Mils2iu( cfg->m_Defaults.pin_length ) );
m_textPinNameDefaultSize = Mils2iu( cfg->m_Defaults.pin_name_size );
m_textPinNumDefaultSize = Mils2iu( cfg->m_Defaults.pin_num_size );
SetRepeatDeltaLabel( cfg->m_Repeat.label_delta );
SetRepeatPinStep( Mils2iu( cfg->m_Repeat.pin_step ) );
SetRepeatStep( wxPoint( cfg->m_Repeat.x_step, cfg->m_Repeat.y_step ) );
m_showPinElectricalTypeName = cfg->m_ShowPinElectricalType;
m_defaultLibWidth = cfg->m_LibWidth;
}
// TODO(JE) does libedit need its own TemplateFieldNames?
auto ee_settings = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();

View File

@ -525,7 +525,8 @@ void SCH_FIELD::SetPosition( const wxPoint& aPosition )
SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );
wxPoint relativePos = aPosition - parentComponent->GetPosition();
parentComponent->GetTransform().InverseTransform().TransformCoordinate( relativePos );
relativePos = parentComponent->GetTransform().
InverseTransform().TransformCoordinate( relativePos );
SetTextPos( relativePos + parentComponent->GetPosition() );
}
@ -541,7 +542,7 @@ wxPoint SCH_FIELD::GetPosition() const
SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );
wxPoint relativePos = GetTextPos() - parentComponent->GetPosition();
parentComponent->GetTransform().TransformCoordinate( relativePos );
relativePos = parentComponent->GetTransform().TransformCoordinate( relativePos );
return relativePos + parentComponent->GetPosition();
}

View File

@ -504,6 +504,9 @@ void KICAD_MANAGER_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
EDA_BASE_FRAME::LoadSettings( aCfg );
auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
wxCHECK( settings, /*void*/);
m_leftWinWidth = settings->m_LeftWinWidth;
}
@ -513,6 +516,9 @@ void KICAD_MANAGER_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
EDA_BASE_FRAME::SaveSettings( aCfg );
auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
wxCHECK( settings, /*void*/);
settings->m_LeftWinWidth = m_leftWin->GetSize().x;
}

View File

@ -182,6 +182,8 @@ void ZONE_CONTAINER::initDataFromSrcInCopyCtor( const ZONE_CONTAINER& aZone )
// (has meaning only for copper zones)
m_netinfo = aZone.m_netinfo;
m_area = aZone.m_area;
SetNeedRefill( aZone.NeedRefill() );
}

View File

@ -532,6 +532,7 @@ PNS_KICAD_IFACE_BASE::PNS_KICAD_IFACE_BASE()
m_board = nullptr;
m_router = nullptr;
m_debugDecorator = nullptr;
m_router = nullptr;
}
@ -1458,7 +1459,7 @@ void PNS_KICAD_IFACE::SetView( KIGFX::VIEW* aView )
m_view = aView;
m_previewItems = new KIGFX::VIEW_GROUP( m_view );
m_previewItems->SetLayer( LAYER_SELECT_OVERLAY ) ;
if(m_view)
m_view->Add( m_previewItems );