FOOTPRINT::GetBoundingHull(): avoid returning a empty hull SHAPE_POLY_SET,
when a footprint contains only texts. empty SHAPE_POLY_SET creates most of time issues (crashes for instance) when containing no data. Ensure the returned SHAPE_POLY_SET contains a minimal hull (a 0.04 mm square) Fixes #7026 https://gitlab.com/kicad/code/kicad/issues/7026
This commit is contained in:
parent
daae68a6b8
commit
08b93bd5ba
|
@ -4,7 +4,7 @@
|
|||
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-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
|
||||
|
@ -712,6 +712,22 @@ SHAPE_POLY_SET FOOTPRINT::GetBoundingHull() const
|
|||
}
|
||||
}
|
||||
|
||||
// If there are some graphic items, build the actual hull.
|
||||
// However if no items, create a minimal polygon (can happen if a footprint
|
||||
// is created with no item: it contains only 2 texts.
|
||||
if( rawPolys.OutlineCount() == 0 )
|
||||
{
|
||||
// generate a small dummy rectangular outline around the anchor
|
||||
const int halfsize = Millimeter2iu( 0.02 );
|
||||
|
||||
rawPolys.NewOutline();
|
||||
// add a square:
|
||||
rawPolys.Append( GetPosition().x - halfsize, GetPosition().y - halfsize );
|
||||
rawPolys.Append( GetPosition().x + halfsize, GetPosition().y - halfsize );
|
||||
rawPolys.Append( GetPosition().x + halfsize, GetPosition().y + halfsize );
|
||||
rawPolys.Append( GetPosition().x - halfsize, GetPosition().y + halfsize );
|
||||
}
|
||||
|
||||
std::vector<wxPoint> convex_hull;
|
||||
BuildConvexHull( convex_hull, rawPolys );
|
||||
|
||||
|
|
Loading…
Reference in New Issue