Fix a few Coverity issues

This commit is contained in:
jean-pierre charras 2020-03-23 16:17:22 +01:00
parent 4d9d1a5380
commit cc47062b17
9 changed files with 25 additions and 17 deletions

View File

@ -364,11 +364,13 @@ void C3D_RENDER_OGL_LEGACY::set_layer_material( PCB_LAYER_ID aLayerID )
case F_Paste:
m_materials.m_Paste.m_Diffuse = get_layer_color( aLayerID );
OGL_SetMaterial( m_materials.m_Paste );
break;
break;
case B_SilkS:
m_materials.m_SilkSBot.m_Diffuse = get_layer_color( aLayerID );
OGL_SetMaterial( m_materials.m_SilkSBot );
break;
case F_SilkS:
m_materials.m_SilkSTop.m_Diffuse = get_layer_color( aLayerID );
OGL_SetMaterial( m_materials.m_SilkSTop );

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2007-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2007-2020 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
@ -263,7 +263,7 @@ void DISPLAY_FOOTPRINTS_FRAME::ReCreateHToolbar()
void DISPLAY_FOOTPRINTS_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
{
auto cfg = dynamic_cast<CVPCB_SETTINGS*>( aCfg );
wxASSERT( cfg );
wxCHECK( cfg, /* void */ );
EDA_DRAW_FRAME::LoadSettings( cfg );
@ -277,7 +277,7 @@ void DISPLAY_FOOTPRINTS_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
void DISPLAY_FOOTPRINTS_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
{
auto cfg = dynamic_cast<CVPCB_SETTINGS*>( aCfg );
wxASSERT( cfg );
wxCHECK( cfg, /* void */ );
EDA_DRAW_FRAME::SaveSettings( cfg );
@ -291,7 +291,7 @@ void DISPLAY_FOOTPRINTS_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
WINDOW_SETTINGS* DISPLAY_FOOTPRINTS_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
{
auto cfg = dynamic_cast<CVPCB_SETTINGS*>( aCfg );
wxASSERT( cfg );
wxCHECK( cfg, nullptr );
return &cfg->m_FootprintViewer;
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Chris Pavlina <pavlina.chris@gmail.com>
* Copyright (C) 2015, 2019 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2015, 2020 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
@ -134,6 +134,9 @@ public:
m_allow_rejustify = false;
m_align_to_grid = true;
m_allow_rejustify = false;
m_align_to_grid = true;
if( cfg )
{
m_allow_rejustify = cfg->m_AutoplaceFields.allow_rejustify;

View File

@ -7,7 +7,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2017 jean-pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2017 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2020 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
@ -122,7 +122,7 @@ DIALOG_ANNOTATE::DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent, const wxString& messag
DIALOG_ANNOTATE::~DIALOG_ANNOTATE()
{
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
auto cfg = static_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
cfg->m_AnnotatePanel.sort_order = GetSortOrder();
cfg->m_AnnotatePanel.method = GetAnnotateAlgo();
@ -132,7 +132,7 @@ DIALOG_ANNOTATE::~DIALOG_ANNOTATE()
void DIALOG_ANNOTATE::InitValues()
{
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
auto cfg = static_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
int option;
// These are always reset to attempt to keep the user out of trouble...

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2020 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
@ -287,7 +287,7 @@ DIALOG_BOM::~DIALOG_BOM()
wxString list( FROM_UTF8( writer.GetString().c_str() ) );
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
auto cfg = static_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
cfg->m_BomPanel.plugins = list.ToStdString();
cfg->m_BomPanel.selected_plugin = m_lbGenerators->GetStringSelection().ToStdString();
@ -297,7 +297,7 @@ DIALOG_BOM::~DIALOG_BOM()
// Read the initialized plugins in config and fill the list of names
void DIALOG_BOM::installGeneratorsList()
{
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
auto cfg = static_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
wxString list = cfg->m_BomPanel.plugins;
wxString active_plugin_name = cfg->m_BomPanel.selected_plugin;

View File

@ -268,6 +268,6 @@ void DIALOG_SCH_EDIT_ONE_FIELD::UpdateField( SCH_FIELD* aField, SCH_SHEET_PATH*
aField->SetText( m_text );
updateText( aField );
if( positioningModified )
if( positioningModified && parent )
static_cast<SCH_ITEM*>( parent )->ClearFieldsAutoplaced();
}

View File

@ -59,6 +59,9 @@ GERBVIEW_SETTINGS::GERBVIEW_SETTINGS() : APP_SETTINGS_BASE( "gerbview", gerbview
m_params.emplace_back( new PARAM_LIST<int>( "gerber_to_pcb_layers",
&m_GerberToPcbLayerMapping, {} ) );
m_params.emplace_back( new PARAM<int>( "gerber_to_pcb_copperlayers_count",
&m_BoardLayersCount, 2 ) );
}

View File

@ -6,7 +6,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2020 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
@ -276,7 +276,7 @@ void LAYERS_MAP_DIALOG::OnResetClick( wxCommandEvent& event )
*/
void LAYERS_MAP_DIALOG::OnStoreSetup( wxCommandEvent& event )
{
auto config = dynamic_cast<GERBVIEW_SETTINGS*>( Kiface().KifaceSettings() );
auto config = static_cast<GERBVIEW_SETTINGS*>( Kiface().KifaceSettings() );
config->m_BoardLayersCount = m_exportBoardCopperLayersCount;
config->m_GerberToPcbLayerMapping.clear();
@ -289,7 +289,7 @@ void LAYERS_MAP_DIALOG::OnStoreSetup( wxCommandEvent& event )
void LAYERS_MAP_DIALOG::OnGetSetup( wxCommandEvent& event )
{
auto config = dynamic_cast<GERBVIEW_SETTINGS*>( Kiface().KifaceSettings() );
auto config = static_cast<GERBVIEW_SETTINGS*>( Kiface().KifaceSettings() );
m_exportBoardCopperLayersCount = config->m_BoardLayersCount;
normalizeBrdLayersCount();

View File

@ -721,7 +721,7 @@ void PCB_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
EDA_DRAW_FRAME::LoadSettings( aCfg );
auto cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
wxASSERT( cfg );
wxCHECK( cfg, /*void*/ );
// Ensure grid id is an existent grid id:
if( (m_LastGridSizeId <= 0) ||