From 27d47743cdecb186c2666c0f4f0056abda41c33b Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 1 Jan 2021 13:08:42 +0100 Subject: [PATCH] SYMBOL_TREE_MODEL_ADAPTER: fix an annoying issue on Windows. Force immediate deletion of the SYMBOL_TREE_MODEL_ADAPTER (do not use Destroy() ) because on Windows, APP_PROGRESS_DIALOG has some side effects on the event loop manager. A side effect is the call of ShowModal() of a dialog following the use of SYMBOL_TREE_MODEL_ADAPTER creating a SYMBOL_TREE_MODEL_ADAPTER has a broken behavior (incorrect modal behavior). --- eeschema/getpart.cpp | 6 ++++-- eeschema/symbol_tree_model_adapter.cpp | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index 158eaa688b..f6b3122fb8 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -93,7 +93,6 @@ PICKED_SYMBOL SCH_BASE_FRAME::PickSymbolFromLibTree( const SCHLIB_FILTER* aFilte bool aAllowFields ) { std::unique_lock dialogLock( DIALOG_CHOOSE_SYMBOL::g_Mutex, std::defer_lock ); - wxString dialogTitle; SYMBOL_LIB_TABLE* libs = Prj().SchSymbolLibTable(); // One CHOOSE_COMPONENT dialog at a time. User probaby can't handle more anyway. @@ -141,11 +140,14 @@ PICKED_SYMBOL SCH_BASE_FRAME::PickSymbolFromLibTree( const SCHLIB_FILTER* aFilte const std::vector< wxString > libNicknames = libs->GetLogicalLibs(); if( !loaded ) - static_cast( adapter.get() )->AddLibraries( libNicknames, this ); + static_cast( adapter.get() )->AddLibraries( libNicknames, + this ); if( aHighlight && aHighlight->IsValid() ) adapter->SetPreselectNode( *aHighlight, /* aUnit */ 0 ); + wxString dialogTitle; + if( adapter->GetFilter() == SYMBOL_TREE_MODEL_ADAPTER::CMP_FILTER_POWER ) dialogTitle.Printf( _( "Choose Power Symbol (%d items loaded)" ), adapter->GetItemCount() ); else diff --git a/eeschema/symbol_tree_model_adapter.cpp b/eeschema/symbol_tree_model_adapter.cpp index 4d72befb2a..1d42d18821 100644 --- a/eeschema/symbol_tree_model_adapter.cpp +++ b/eeschema/symbol_tree_model_adapter.cpp @@ -85,7 +85,12 @@ void SYMBOL_TREE_MODEL_ADAPTER::AddLibraries( const std::vector& aNick if( prg ) { - prg->Destroy(); + // Force immediate deletion of the SYMBOL_TREE_MODEL_ADAPTER (do not use Destroy() ) + // because on Windows, APP_PROGRESS_DIALOG has some side effects on the event loop + // manager. A side effect is the call of ShowModal() of a dialog following + // the use of SYMBOL_TREE_MODEL_ADAPTER creating a SYMBOL_TREE_MODEL_ADAPTER + // has a broken behavior (incorrect modal behavior). + delete prg; m_show_progress = false; } }