From 3e9eb3c8acab5131341f9452988a959387cb376c Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 5 Mar 2021 15:30:12 +0000 Subject: [PATCH] More complete fix for crasher JP found. Fixes https://gitlab.com/kicad/code/kicad/issues/7806 --- include/board_design_settings.h | 32 ++--------------- pcbnew/board_design_settings.cpp | 60 ++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 29 deletions(-) diff --git a/include/board_design_settings.h b/include/board_design_settings.h index 8ca74f6d72..98c32233ca 100644 --- a/include/board_design_settings.h +++ b/include/board_design_settings.h @@ -541,47 +541,21 @@ public: /** * @return the current diff pair track width, according to the selected options * ( using the default netclass value or a preset/custom value ) - * the default netclass is always in m_DiffPairDimensionsList[0]. */ - inline int GetCurrentDiffPairWidth() const - { - if( m_useCustomDiffPair ) - return m_customDiffPair.m_Width; - else if( m_diffPairIndex < m_DiffPairDimensionsList.size() ) - return m_DiffPairDimensionsList[m_diffPairIndex].m_Width; - else - return GetCurrentTrackWidth(); - } + int GetCurrentDiffPairWidth() const; /** * @return the current diff pair gap, according to the selected options * ( using the default netclass value or a preset/custom value ) - * the default netclass is always in m_DiffPairDimensionsList[0]. */ - inline int GetCurrentDiffPairGap() const - { - if( m_useCustomDiffPair ) - return m_customDiffPair.m_Gap; - else if( m_diffPairIndex < m_DiffPairDimensionsList.size() ) - return m_DiffPairDimensionsList[m_diffPairIndex].m_Gap; - else - return GetSmallestClearanceValue(); - } + int GetCurrentDiffPairGap() const; /** * @return the current diff pair via gap, according to the selected options * ( using the default netclass value or a preset/custom value ) * the default netclass is always in m_DiffPairDimensionsList[0]. */ - inline int GetCurrentDiffPairViaGap() const - { - if( m_useCustomDiffPair ) - return m_customDiffPair.m_ViaGap; - else if( m_diffPairIndex < m_DiffPairDimensionsList.size() ) - return m_DiffPairDimensionsList[m_diffPairIndex].m_ViaGap; - else - return GetSmallestClearanceValue(); - } + int GetCurrentDiffPairViaGap() const; /** * @param aValue The minimum distance between the edges of two holes or 0 to disable diff --git a/pcbnew/board_design_settings.cpp b/pcbnew/board_design_settings.cpp index 2265db8fab..a88f22e366 100644 --- a/pcbnew/board_design_settings.cpp +++ b/pcbnew/board_design_settings.cpp @@ -974,6 +974,66 @@ void BOARD_DESIGN_SETTINGS::SetDiffPairIndex( unsigned aIndex ) } +int BOARD_DESIGN_SETTINGS::GetCurrentDiffPairWidth() const +{ + if( m_useCustomDiffPair ) + { + return m_customDiffPair.m_Width; + } + else if( m_diffPairIndex == 0 ) + { + if( GetNetClasses().GetDefaultPtr()->HasDiffPairWidth() ) + return GetNetClasses().GetDefaultPtr()->GetDiffPairWidth(); + else + return GetNetClasses().GetDefaultPtr()->GetTrackWidth(); + } + else + { + return m_DiffPairDimensionsList[m_diffPairIndex].m_Width; + } +} + + +int BOARD_DESIGN_SETTINGS::GetCurrentDiffPairGap() const +{ + if( m_useCustomDiffPair ) + { + return m_customDiffPair.m_Gap; + } + else if( m_diffPairIndex == 0 ) + { + if( GetNetClasses().GetDefaultPtr()->HasDiffPairGap() ) + return GetNetClasses().GetDefaultPtr()->GetDiffPairGap(); + else + return GetNetClasses().GetDefaultPtr()->GetClearance(); + } + else + { + return m_DiffPairDimensionsList[m_diffPairIndex].m_Gap; + } +} + + +int BOARD_DESIGN_SETTINGS::GetCurrentDiffPairViaGap() const +{ + if( m_useCustomDiffPair ) + { + return m_customDiffPair.m_ViaGap; + } + else if( m_diffPairIndex == 0 ) + { + if( GetNetClasses().GetDefaultPtr()->HasDiffPairViaGap() ) + return GetNetClasses().GetDefaultPtr()->GetDiffPairViaGap(); + else + return GetCurrentDiffPairGap(); + } + else + { + return m_DiffPairDimensionsList[m_diffPairIndex].m_ViaGap; + } +} + + void BOARD_DESIGN_SETTINGS::SetMinHoleSeparation( int aDistance ) { m_HoleToHoleMin = aDistance;