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).
This commit is contained in:
jean-pierre charras 2021-01-01 13:08:42 +01:00
parent a572be54e1
commit 27d47743cd
2 changed files with 10 additions and 3 deletions

View File

@ -93,7 +93,6 @@ PICKED_SYMBOL SCH_BASE_FRAME::PickSymbolFromLibTree( const SCHLIB_FILTER* aFilte
bool aAllowFields )
{
std::unique_lock<std::mutex> 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<SYMBOL_TREE_MODEL_ADAPTER*>( adapter.get() )->AddLibraries( libNicknames, this );
static_cast<SYMBOL_TREE_MODEL_ADAPTER*>( 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

View File

@ -85,7 +85,12 @@ void SYMBOL_TREE_MODEL_ADAPTER::AddLibraries( const std::vector<wxString>& 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;
}
}