Fix a couple of Coverity issues.

This commit is contained in:
Jeff Young 2020-01-12 21:07:41 +00:00
parent 8d0f31f6f4
commit d24bd5c832
2 changed files with 19 additions and 14 deletions

View File

@ -1463,9 +1463,18 @@ double MODULE::CoverageRatio( const GENERAL_COLLECTOR& aCollector ) const
} }
SHAPE_POLY_SET uncoveredRegion; SHAPE_POLY_SET uncoveredRegion;
try
{
uncoveredRegion.BooleanSubtract( coveredRegion, holes, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE ); uncoveredRegion.BooleanSubtract( coveredRegion, holes, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
uncoveredRegion.Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE ); uncoveredRegion.Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
uncoveredRegion.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE ); uncoveredRegion.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
}
catch( ClipperLib::clipperException& )
{
// better to be conservative (this will result in the disambiguate dialog)
return 1.0;
}
double uncoveredRegionArea = polygonArea( uncoveredRegion ); double uncoveredRegionArea = polygonArea( uncoveredRegion );
double coveredArea = moduleArea - uncoveredRegionArea; double coveredArea = moduleArea - uncoveredRegionArea;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2014-2017 CERN * Copyright (C) 2014-2017 CERN
* Copyright (C) 2014-2019 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2014-2020 KiCad Developers, see AUTHORS.txt for contributors.
* @author Tomasz Włostowski <tomasz.wlostowski@cern.ch> * @author Tomasz Włostowski <tomasz.wlostowski@cern.ch>
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
@ -23,9 +23,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <cstdint>
#include <thread> #include <thread>
#include <mutex>
#include <algorithm> #include <algorithm>
#include <future> #include <future>
@ -34,15 +32,11 @@
#include <class_module.h> #include <class_module.h>
#include <class_edge_mod.h> #include <class_edge_mod.h>
#include <class_drawsegment.h> #include <class_drawsegment.h>
#include <class_track.h>
#include <class_pcb_text.h> #include <class_pcb_text.h>
#include <class_pcb_target.h> #include <class_pcb_target.h>
#include <connectivity/connectivity_data.h> #include <connectivity/connectivity_data.h>
#include <board_commit.h> #include <board_commit.h>
#include <widgets/progress_reporter.h> #include <widgets/progress_reporter.h>
#include <geometry/shape_poly_set.h> #include <geometry/shape_poly_set.h>
#include <geometry/shape_file_io.h> #include <geometry/shape_file_io.h>
#include <geometry/convex_hull.h> #include <geometry/convex_hull.h>
@ -53,8 +47,6 @@
#include "zone_filler.h" #include "zone_filler.h"
#include <advanced_config.h> // To be removed later, when the zone fill option will be always allowed
class PROGRESS_REPORTER_HIDER class PROGRESS_REPORTER_HIDER
{ {
public: public:
@ -82,8 +74,12 @@ static const bool s_DumpZonesWhenFilling = false;
ZONE_FILLER::ZONE_FILLER( BOARD* aBoard, COMMIT* aCommit ) : ZONE_FILLER::ZONE_FILLER( BOARD* aBoard, COMMIT* aCommit ) :
m_board( aBoard ), m_brdOutlinesValid( false ), m_commit( aCommit ), m_board( aBoard ),
m_progressReporter( nullptr ) m_brdOutlinesValid( false ),
m_commit( aCommit ),
m_progressReporter( nullptr ),
m_high_def( 9 ),
m_low_def( 6 )
{ {
} }