From 9f2d83c14892d76e79130eb0db06dc046afc87be Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 9 Dec 2011 11:36:00 +0100 Subject: [PATCH] Pcbnew: fix bad initialization of default track width and vias sizes when starting pcbnew with no board loaded. --- pcbnew/class_board.cpp | 3 ++- pcbnew/class_board_design_settings.cpp | 2 +- pcbnew/class_netclass.cpp | 14 ++++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index a867c6a46a..547245d75b 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -59,7 +59,8 @@ BOARD::BOARD() : m_ViaSizeSelector = 0; m_TrackWidthSelector = 0; - // Initialize default values. + // Initialize default values in default netclass. + m_NetClasses.GetDefault()->SetParams(); SetCurrentNetClass( m_NetClasses.GetDefault()->GetName() ); } diff --git a/pcbnew/class_board_design_settings.cpp b/pcbnew/class_board_design_settings.cpp index 8f20be0a80..8f96069cc8 100644 --- a/pcbnew/class_board_design_settings.cpp +++ b/pcbnew/class_board_design_settings.cpp @@ -32,7 +32,7 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() m_EdgeSegmentWidth = 100; // current graphic line width (EDGE layer only) m_PcbTextWidth = 100; // current Pcb (not module) Text width m_PcbTextSize = wxSize( 500, 500 ); // current Pcb (not module) Text size - m_TrackMinWidth = 80; // track min value for width ((min copper size value + m_TrackMinWidth = 100; // track min value for width ((min copper size value m_ViasMinSize = 350; // vias (not micro vias) min diameter m_ViasMinDrill = 200; // vias (not micro vias) min drill diameter m_MicroViasMinSize = 200; // micro vias (not vias) min diameter diff --git a/pcbnew/class_netclass.cpp b/pcbnew/class_netclass.cpp index a46536dc77..09563bce7b 100644 --- a/pcbnew/class_netclass.cpp +++ b/pcbnew/class_netclass.cpp @@ -66,12 +66,14 @@ void NETCLASS::SetParams( const NETCLASS* defaults ) SetuViaDrill( defaults->GetuViaDrill() ); } else - { // We should use m_Parent->GetDesignSettings() - // But when the NETCLASSES constructor is called - // (it call NETCLASS constructor), the m_Parent constructor (see BOARD::BOARD) - // is not run, and GetDesignSettings() return a bad value - // TODO: see how change that. - const BOARD_DESIGN_SETTINGS& g = m_Parent->GetDesignSettings(); // like that? + { // Note: + // We use m_Parent->GetDesignSettings() to get some default values + // But when this function is called when instantiating a BOARD class, + // by the NETCLASSES constructor that calls NETCLASS constructor, + // the BOARD constructor (see BOARD::BOARD) is not yet run, + // and BOARD::m_designSettings contains not yet initialized values. + // So inside the BOARD constructor itself, you SHOULD recall SetParams + const BOARD_DESIGN_SETTINGS& g = m_Parent->GetDesignSettings(); SetTrackWidth( g.m_TrackMinWidth ); SetViaDiameter( g.m_ViasMinSize );