Fix missing initialization of colors settings of a board, when created by a python script.

A pointer was not initialized, therefore plots from a python script sometimes crash.

Fixes: lp:1721166
https://bugs.launchpad.net/kicad/+bug/1721166
This commit is contained in:
jean-pierre charras 2017-10-08 16:08:42 +02:00
parent d6c0d320db
commit 246f8cae24
3 changed files with 15 additions and 4 deletions

View File

@ -66,6 +66,12 @@
*/
wxPoint BOARD_ITEM::ZeroOffset( 0, 0 );
// this is a dummy colors settings (defined colors are the vdefulat values)
// used to initialize the board.
// these settings will be overriden later, depending on the draw frame that displays the board.
// However, when a board is created by a python script, outside a frame, the colors must be set
// so dummyColorsSettings provide this default initialization
static COLORS_DESIGN_SETTINGS dummyColorsSettings( FRAME_PCB );
BOARD::BOARD() :
BOARD_ITEM_CONTAINER( (BOARD_ITEM*) NULL, PCB_T ),
@ -74,6 +80,7 @@ BOARD::BOARD() :
// we have not loaded a board yet, assume latest until then.
m_fileFormatVersionAtLoad = LEGACY_BOARD_FILE_VERSION;
m_colorsSettings = &dummyColorsSettings;
m_Status_Pcb = 0; // Status word: bit 1 = calculate.
m_CurrentZoneContour = NULL; // This ZONE_CONTAINER handle the
// zone contour currently in progress

View File

@ -57,8 +57,12 @@
COLOR4D BRDITEMS_PLOTTER::getColor( LAYER_NUM aLayer )
{
COLOR4D color = m_board->Colors().GetLayerColor( ToLAYER_ID( aLayer ) );
// A hack to avoid plotting ahite itmen in white color, expecting the paper
// is also white: use a non white color:
if( color == COLOR4D::WHITE )
color = COLOR4D( LIGHTGRAY );
return color;
}