From 58100b62e6ea7e9a1a1337be57ea887ec5dbcdca Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 4 Sep 2018 17:14:24 +0100 Subject: [PATCH] Legacy colors are not stored under a "4D" name. --- common/config_params.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/common/config_params.cpp b/common/config_params.cpp index 7ebabbacbb..1f566b2006 100644 --- a/common/config_params.cpp +++ b/common/config_params.cpp @@ -276,22 +276,30 @@ void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig ) const if( !m_Pt_param || !aConfig ) return; - // First try reading old format - EDA_COLOR_T itmp = ColorByName( aConfig->Read( m_Ident, wxT( "NONE" ) ) ); - COLOR4D wtmp = COLOR4D::UNSPECIFIED; + COLOR4D temp; - if( itmp == UNSPECIFIED_COLOR ) + if( aConfig->HasEntry( m_Ident ) ) { - // Next try reading new format - if( !wtmp.SetFromWxString( aConfig->Read( m_Ident, wxT( "NONE" ) ) ) ) - wtmp = m_Default; - } - else - { - wtmp = COLOR4D( itmp ); + if( temp.SetFromWxString( aConfig->Read( m_Ident, wxT( "NONE" ) ) ) ) + { + *m_Pt_param = temp; + return; + } } - *m_Pt_param = wtmp; + // If no luck, try reading legacy format + wxString legacy_Ident = m_Ident; + legacy_Ident.Replace( wxT( "4D" ), wxEmptyString ); + + EDA_COLOR_T old = ColorByName( aConfig->Read( legacy_Ident, wxT( "NONE" ) ) ); + + if( old != UNSPECIFIED_COLOR ) + { + *m_Pt_param = COLOR4D( old ); + return; + } + + *m_Pt_param = m_Default; }