From f364e81a91c4da9c311f28aa1d5c5822d0501ce8 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 16 Feb 2019 10:25:34 +0100 Subject: [PATCH] Symbol editor: fix missing initialization in LIB_TREE_MODEL_ADAPTER::ColWidth(). The text size (in pixels) was never initialized (always 0) for the Column id 0. --- common/lib_tree_model_adapter.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/lib_tree_model_adapter.cpp b/common/lib_tree_model_adapter.cpp index 646f9d746c..422ec5debc 100644 --- a/common/lib_tree_model_adapter.cpp +++ b/common/lib_tree_model_adapter.cpp @@ -377,7 +377,13 @@ int LIB_TREE_MODEL_ADAPTER::ColWidth( LIB_TREE_NODE& aTree, int aCol, wxString c continue; if( node->Score > 0 ) + { + // Ensure the text size is up to date: + if( node->VisLen == 0 ) + node->VisLen = m_widget->GetTextExtent( node->Name ).x; + longest = std::max( longest, node->VisLen + padding + indent ); + } if( !m_widget->IsExpanded( item ) ) continue; @@ -385,7 +391,12 @@ int LIB_TREE_MODEL_ADAPTER::ColWidth( LIB_TREE_NODE& aTree, int aCol, wxString c for( auto& childNode : node->Children ) { if( childNode->Score > 0 ) + { + if( childNode->VisLen == 0 ) + childNode->VisLen = m_widget->GetTextExtent( childNode->Name ).x; + longest = std::max( longest, childNode->VisLen + padding + 2 * indent ); + } } }