Coverity issue fixes.

This commit is contained in:
Wayne Stambaugh 2021-11-13 11:38:19 -05:00
parent fb734a6313
commit 53f5d616aa
8 changed files with 65 additions and 10 deletions

View File

@ -2155,6 +2155,9 @@ int CONNECTION_GRAPH::RunERC()
for( CONNECTION_SUBGRAPH* subgraph : m_subgraphs )
{
// There shouldn't be any null sub-graph pointers.
wxCHECK2( subgraph, continue );
// Graph is supposed to be up-to-date before calling RunERC()
wxASSERT( !subgraph->m_dirty );
@ -2238,13 +2241,14 @@ int CONNECTION_GRAPH::RunERC()
bool CONNECTION_GRAPH::ercCheckMultipleDrivers( const CONNECTION_SUBGRAPH* aSubgraph )
{
wxCHECK( aSubgraph, false );
/*
* This was changed late in 6.0 to fix https://gitlab.com/kicad/code/kicad/-/issues/9367
* so I'm going to leave the original code in for just a little while. If anyone comes
* across this in 7.0 development (or later), feel free to delete.
*/
#if 0
if( aSubgraph && aSubgraph->m_second_driver )
if( aSubgraph->m_second_driver )
{
SCH_ITEM* primary = aSubgraph->m_first_driver;
SCH_ITEM* secondary = aSubgraph->m_second_driver;
@ -2270,7 +2274,7 @@ bool CONNECTION_GRAPH::ercCheckMultipleDrivers( const CONNECTION_SUBGRAPH* aSubg
return false;
}
#else
if( aSubgraph && aSubgraph->m_multiple_drivers )
if( aSubgraph->m_multiple_drivers )
{
for( SCH_ITEM* driver : aSubgraph->m_drivers )
{

View File

@ -327,7 +327,18 @@ SCH_EDIT_FRAME::~SCH_EDIT_FRAME()
// Close the project if we are standalone, so it gets cleaned up properly
if( Kiface().IsSingle() )
{
try
{
GetSettingsManager()->UnloadProject( &Prj(), false );
}
catch( const nlohmann::detail::type_error& exc )
{
// This may be overkill and could be an assertion but we are more likely to
// find any settings manager errors this way.
wxLogError( wxT( "Settings exception '%s' occurred." ), exc.what() );
}
}
}

View File

@ -56,6 +56,8 @@
#include <trigo.h>
#include <view/view.h>
#include <view/view_controls.h>
#include <wx/log.h>
SELECTION_CONDITION EE_CONDITIONS::SingleSymbol = []( const SELECTION& aSel )
{
@ -1043,8 +1045,18 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const
text->GetEffectiveTextShape()->Collide( poss, closestDist, &dist );
}
else if( symbol )
{
try
{
bbox = symbol->GetBodyBoundingBox();
}
catch( const boost::bad_pointer& exc )
{
// This may be overkill and could be an assertion but we are more likely to
// find any boost pointer container errors this way.
wxLogError( wxT( "Boost bad pointer exception '%s' occurred." ), exc.what() );
}
SHAPE_RECT rect( bbox.GetPosition(), bbox.GetWidth(), bbox.GetHeight() );
if( bbox.Contains( pos ) )

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2018, 2021 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
@ -32,7 +32,9 @@ public:
WX_SPLITTER_WINDOW( wxWindow *parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxSP_3D, const wxString& name = wxT( "splitter" ) ) :
wxSplitterWindow( parent, id, pos, size, style, name )
wxSplitterWindow( parent, id, pos, size, style, name ),
m_minFirstPane( -1 ),
m_minSecondPane( -1 )
{
this->Connect( wxEVT_SIZE, wxSizeEventHandler( WX_SPLITTER_WINDOW::OnSize ) );
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2021 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
@ -53,6 +53,10 @@ FOOTPRINT_EDITOR_SETTINGS::FOOTPRINT_EDITOR_SETTINGS() :
m_MagneticItems.tracks = MAGNETIC_OPTIONS::NO_EFFECT;
m_MagneticItems.graphics = true;
m_AuiPanels.appearance_panel_tab = 0;
m_AuiPanels.right_panel_width = -1;
m_AuiPanels.show_layer_manager = true;
m_params.emplace_back( new PARAM<int>( "window.lib_width",
&m_LibWidth, 250 ) );

View File

@ -284,8 +284,17 @@ void PCB_BASE_FRAME::FocusOnItem( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer )
SHAPE_POLY_SET dialogPoly( BOX2D( view->ToWorld( dialogPos, true ),
view->ToWorld( dialog->GetSize(), false ) ) );
try
{
viewportPoly.BooleanSubtract( dialogPoly, SHAPE_POLY_SET::PM_FAST );
}
catch( const ClipperLib::clipperException& exc )
{
// This may be overkill and could be an assertion but we are more likely to find
// any clipper errors this way.
wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
}
}
SHAPE_POLY_SET itemPoly, clippedPoly;
@ -324,7 +333,8 @@ void PCB_BASE_FRAME::FocusOnItem( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer )
itemPoly.Append( item_bbox.GetOrigin() );
itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( item_bbox.GetWidth(), 0 ) );
itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( 0, item_bbox.GetHeight() ) );
itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( item_bbox.GetWidth(), item_bbox.GetHeight() ) );
itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( item_bbox.GetWidth(),
item_bbox.GetHeight() ) );
break;
}
}

View File

@ -1749,6 +1749,9 @@ static void updateArcFromConstructionMgr( const KIGFX::PREVIEW::ARC_GEOM_MANAGER
bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, bool aImmediateMode )
{
PCB_SHAPE*& graphic = *aGraphic;
wxCHECK( graphic, 0 );
PCB_LAYER_ID drawingLayer = m_frame->GetActiveLayer();
m_lineWidth = getSegmentWidth( drawingLayer );

View File

@ -2327,7 +2327,16 @@ int PCB_SELECTION_TOOL::hitTestDistance( const wxPoint& aWhere, BOARD_ITEM* aIte
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( aItem );
EDA_RECT bbox = footprint->GetBoundingBox( false, false );
try
{
footprint->GetBoundingHull().Collide( loc, aMaxDistance, &distance );
}
catch( const ClipperLib::clipperException& exc )
{
// This may be overkill and could be an assertion but we are more likely to find
// any clipper errors this way.
wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
}
// Consider footprints larger than the viewport only as a last resort
if( bbox.GetHeight() > viewport.GetHeight() || bbox.GetWidth() > viewport.GetWidth() )