7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 00:21:31 +00:00

Prevent events from firing in the main window during load

Closing the source window while another wx loop is running can lead to
async events being processed, leaving the current stack out of scope

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19341
This commit is contained in:
Seth Hillbrand 2024-12-20 11:22:41 -08:00
parent 2fb8340466
commit 6d99f62c96
3 changed files with 12 additions and 1 deletions

View File

@ -1195,6 +1195,7 @@ void SCH_EDIT_FRAME::OnUpdatePCB()
}
KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
wxEventBlocker blocker( this );
if( !frame )
{
@ -1425,6 +1426,7 @@ void SCH_EDIT_FRAME::OnOpenPcbnew()
}
else
{
wxEventBlocker blocker(this);
KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
if( !frame )

View File

@ -712,6 +712,9 @@ void PANEL_JOBS::EnsurePcbSchFramesOpen()
wxFileName boardfn = project.GetProjectFullName();
boardfn.SetExt( FILEEXT::PcbFileExtension );
// Prevent our window from being closed during the open process
wxEventBlocker blocker( this );
frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
}
@ -729,6 +732,8 @@ void PANEL_JOBS::EnsurePcbSchFramesOpen()
wxFileName schFn = project.GetProjectFullName();
schFn.SetExt( FILEEXT::KiCadSchematicFileExtension );
wxEventBlocker blocker( this );
frame->OpenProjectFiles( std::vector<wxString>( 1, schFn.GetFullPath() ) );
}
}

View File

@ -1315,7 +1315,7 @@ void PCB_EDIT_FRAME::ShowBoardSetupDialog( const wxString& aInitialPage )
if( !aInitialPage.IsEmpty() )
dlg.SetInitialPage( aInitialPage, wxEmptyString );
// Assign dlg to the m_boardSetupDlg pointer to track its status.
m_boardSetupDlg = &dlg;
@ -1950,6 +1950,7 @@ int PCB_EDIT_FRAME::TestStandalone()
if( !frame->IsShownOnScreen() )
{
wxEventBlocker blocker( this );
wxFileName fn( Prj().GetProjectPath(), Prj().GetProjectName(),
FILEEXT::KiCadSchematicFileExtension );
@ -2080,11 +2081,14 @@ void PCB_EDIT_FRAME::RunEeschema()
}
catch( const IO_ERROR& err )
{
DisplayErrorMessage( this, _( "Eeschema failed to load." ) + wxS( "\n" ) + err.What() );
return;
}
}
wxEventBlocker blocker( this );
// If Kiway() cannot create the eeschema frame, it shows a error message, and
// frame is null
if( !frame )