From 598ed8b3948ac29341ff025620d58e59d270f8c7 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 30 May 2020 14:08:00 +0200 Subject: [PATCH] toolbars_lib_view.cpp and toolbars_libedit.cpp: do not recreate comboboxes when clearing toolbars. Clearing toolbars delete only tools, not other widgets. recreating comboboxes creates strange cosmetic issues. Fixes #4542 https://gitlab.com/kicad/code/kicad/issues/4542 --- eeschema/lib_view_frame.cpp | 3 ++- eeschema/libedit/toolbars_libedit.cpp | 4 +++- eeschema/toolbars_lib_view.cpp | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/eeschema/lib_view_frame.cpp b/eeschema/lib_view_frame.cpp index ffa42033b3..ee34b47867 100644 --- a/eeschema/lib_view_frame.cpp +++ b/eeschema/lib_view_frame.cpp @@ -102,7 +102,8 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame wxDefaultPosition, wxDefaultSize, aFrameType == FRAME_SCH_VIEWER_MODAL ? LIB_VIEW_STYLE_MODAL : LIB_VIEW_STYLE, aFrameType == FRAME_SCH_VIEWER_MODAL ? LIB_VIEW_NAME_MODAL : LIB_VIEW_NAME ), - m_libList( nullptr ), m_cmpList( nullptr ), m_previewItem( nullptr ) + m_unitChoice( nullptr ), m_libList( nullptr ), + m_cmpList( nullptr ), m_previewItem( nullptr ) { wxASSERT( aFrameType == FRAME_SCH_VIEWER || aFrameType == FRAME_SCH_VIEWER_MODAL ); diff --git a/eeschema/libedit/toolbars_libedit.cpp b/eeschema/libedit/toolbars_libedit.cpp index 6b5a4420c8..9d87d791ee 100644 --- a/eeschema/libedit/toolbars_libedit.cpp +++ b/eeschema/libedit/toolbars_libedit.cpp @@ -112,7 +112,9 @@ void LIB_EDIT_FRAME::ReCreateHToolbar() m_mainToolBar->Add( EE_ACTIONS::showDeMorganAlternate, ACTION_TOOLBAR::TOGGLE ); KiScaledSeparator( m_mainToolBar, this ); - m_unitSelectBox = new wxComboBox( m_mainToolBar, ID_LIBEDIT_SELECT_PART_NUMBER, wxEmptyString, + + if( m_unitSelectBox == nullptr ) + m_unitSelectBox = new wxComboBox( m_mainToolBar, ID_LIBEDIT_SELECT_PART_NUMBER, wxEmptyString, wxDefaultPosition, wxSize( LISTBOX_WIDTH, -1 ), 0, nullptr, wxCB_READONLY ); m_mainToolBar->AddControl( m_unitSelectBox ); diff --git a/eeschema/toolbars_lib_view.cpp b/eeschema/toolbars_lib_view.cpp index 817ce24b76..d2a14829b5 100644 --- a/eeschema/toolbars_lib_view.cpp +++ b/eeschema/toolbars_lib_view.cpp @@ -69,8 +69,10 @@ void LIB_VIEW_FRAME::ReCreateHToolbar() toolbar->Add( EE_ACTIONS::showDeMorganAlternate, ACTION_TOOLBAR::TOGGLE ); KiScaledSeparator( m_mainToolBar, this ); - m_unitChoice = new wxChoice( m_mainToolBar, ID_LIBVIEW_SELECT_PART_NUMBER, - wxDefaultPosition, wxSize( 150, -1 ) ); + + if( m_unitChoice == nullptr ) + m_unitChoice = new wxChoice( m_mainToolBar, ID_LIBVIEW_SELECT_PART_NUMBER, + wxDefaultPosition, wxSize( 150, -1 ) ); m_mainToolBar->AddControl( m_unitChoice ); KiScaledSeparator( m_mainToolBar, this );