Don't capture references to local variables for CallAfter.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16934
This commit is contained in:
Jeff Young 2024-02-14 18:15:49 +00:00
parent 0ead8a14a1
commit 9d40374baf
14 changed files with 27 additions and 19 deletions

View File

@ -483,7 +483,7 @@ void EDA_BASE_FRAME::ReCreateMenuBar()
* ensure that they do not occur within the same event handling call stack. * ensure that they do not occur within the same event handling call stack.
*/ */
CallAfter( [&]() CallAfter( [this]()
{ {
if( !m_isClosing ) if( !m_isClosing )
doReCreateMenuBar(); doReCreateMenuBar();

View File

@ -133,7 +133,7 @@ PROPERTIES_PANEL::PROPERTIES_PANEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame )
Bind( wxEVT_SIZE, Bind( wxEVT_SIZE,
[&]( wxSizeEvent& aEvent ) [&]( wxSizeEvent& aEvent )
{ {
CallAfter( [&]() CallAfter( [this]()
{ {
RecalculateSplitterPos(); RecalculateSplitterPos();
} ); } );

View File

@ -80,10 +80,12 @@ void SEARCH_PANE_LISTVIEW::GetSelectRowsList( std::vector<long>& aSelectedList )
void SEARCH_PANE_LISTVIEW::OnItemActivated( wxListEvent& aEvent ) void SEARCH_PANE_LISTVIEW::OnItemActivated( wxListEvent& aEvent )
{ {
long item = aEvent.GetIndex();
CallAfter( CallAfter(
[&]() [this, item]()
{ {
m_handler->ActivateItem( aEvent.GetIndex() ); m_handler->ActivateItem( item );
} ); } );
m_selectionDirty = true; m_selectionDirty = true;

View File

@ -541,7 +541,7 @@ WIDGET_HOTKEY_LIST::WIDGET_HOTKEY_LIST( wxWindow* aParent, HOTKEY_STORE& aHotkey
dv->GetColumn( 2 )->SetMinWidth( aParent->GetTextExtent( longKey ).x + pad ); dv->GetColumn( 2 )->SetMinWidth( aParent->GetTextExtent( longKey ).x + pad );
dv->GetColumn( 3 )->SetMinWidth( aParent->GetTextExtent( command_header ).x * 5 + pad ); dv->GetColumn( 3 )->SetMinWidth( aParent->GetTextExtent( command_header ).x * 5 + pad );
CallAfter( [&]() CallAfter( [this]()
{ {
GetDataView()->Update(); GetDataView()->Update();
} ); } );

View File

@ -164,7 +164,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa
// Register a call to update the toolbar sizes. It can't be done immediately because // Register a call to update the toolbar sizes. It can't be done immediately because
// it seems to require some sizes calculated that aren't yet (at least on GTK). // it seems to require some sizes calculated that aren't yet (at least on GTK).
CallAfter( [&]() CallAfter( [this]()
{ {
// Ensure the controls on the toolbars all are correctly sized // Ensure the controls on the toolbars all are correctly sized
UpdateToolbarControlSizes(); UpdateToolbarControlSizes();

View File

@ -116,7 +116,7 @@ void SCH_PROPERTIES_PANEL::AfterCommit()
rebuildProperties( selection ); rebuildProperties( selection );
CallAfter( [&]() CallAfter( [this]()
{ {
m_frame->GetCanvas()->SetFocus(); m_frame->GetCanvas()->SetFocus();
} ); } );

View File

@ -198,7 +198,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent )
// Register a call to update the toolbar sizes. It can't be done immediately because // Register a call to update the toolbar sizes. It can't be done immediately because
// it seems to require some sizes calculated that aren't yet (at least on GTK). // it seems to require some sizes calculated that aren't yet (at least on GTK).
CallAfter( [&]() CallAfter( [this]()
{ {
// Ensure the controls on the toolbars all are correctly sized // Ensure the controls on the toolbars all are correctly sized
UpdateToolbarControlSizes(); UpdateToolbarControlSizes();

View File

@ -226,11 +226,12 @@ void UPDATE_MANAGER::CheckForUpdate( wxWindow* aNoticeParent )
if( response.version != settings->m_lastReceivedUpdate ) if( response.version != settings->m_lastReceivedUpdate )
{ {
aNoticeParent->CallAfter( aNoticeParent->CallAfter(
[&]() [aNoticeParent, response]()
{ {
auto notice = new DIALOG_UPDATE_NOTICE( auto notice = new DIALOG_UPDATE_NOTICE( aNoticeParent,
aNoticeParent, response.version, response.details_url, response.version,
response.downloads_url ); response.details_url,
response.downloads_url );
int retCode = notice->ShowModal(); int retCode = notice->ShowModal();
@ -238,6 +239,8 @@ void UPDATE_MANAGER::CheckForUpdate( wxWindow* aNoticeParent )
{ {
// basically saving the last received update prevents us from // basically saving the last received update prevents us from
// prompting again // prompting again
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
KICAD_SETTINGS* settings = mgr.GetAppSettings<KICAD_SETTINGS>();
settings->m_lastReceivedUpdate = response.version; settings->m_lastReceivedUpdate = response.version;
} }
} ); } );

View File

@ -223,7 +223,7 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
// Register a call to update the toolbar sizes. It can't be done immediately because // Register a call to update the toolbar sizes. It can't be done immediately because
// it seems to require some sizes calculated that aren't yet (at least on GTK). // it seems to require some sizes calculated that aren't yet (at least on GTK).
CallAfter( [&]() CallAfter( [this]()
{ {
// Ensure the controls on the toolbars all are correctly sized // Ensure the controls on the toolbars all are correctly sized
UpdateToolbarControlSizes(); UpdateToolbarControlSizes();

View File

@ -302,7 +302,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
// Register a call to update the toolbar sizes. It can't be done immediately because // Register a call to update the toolbar sizes. It can't be done immediately because
// it seems to require some sizes calculated that aren't yet (at least on GTK). // it seems to require some sizes calculated that aren't yet (at least on GTK).
CallAfter( CallAfter(
[&]() [this]()
{ {
// Ensure the controls on the toolbars all are correctly sized // Ensure the controls on the toolbars all are correctly sized
UpdateToolbarControlSizes(); UpdateToolbarControlSizes();

View File

@ -451,7 +451,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
#ifdef __WXMAC__ #ifdef __WXMAC__
if( Kiface().IsSingle() ) if( Kiface().IsSingle() )
{ {
CallAfter( [&]() CallAfter( [this]()
{ {
m_appearancePanel->OnBoardChanged(); m_appearancePanel->OnBoardChanged();
} ); } );
@ -460,7 +460,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
// Register a call to update the toolbar sizes. It can't be done immediately because // Register a call to update the toolbar sizes. It can't be done immediately because
// it seems to require some sizes calculated that aren't yet (at least on GTK). // it seems to require some sizes calculated that aren't yet (at least on GTK).
CallAfter( [&]() CallAfter( [this]()
{ {
// Ensure the controls on the toolbars all are correctly sized // Ensure the controls on the toolbars all are correctly sized
UpdateToolbarControlSizes(); UpdateToolbarControlSizes();

View File

@ -994,7 +994,7 @@ void APPEARANCE_CONTROLS::OnNetGridMouseEvent( wxMouseEvent& aEvent )
else if( aEvent.Dragging() ) else if( aEvent.Dragging() )
{ {
// not allowed // not allowed
CallAfter( [&]() CallAfter( [this]()
{ {
m_netsGrid->ClearSelection(); m_netsGrid->ClearSelection();
} ); } );

View File

@ -122,7 +122,7 @@ void PCB_PROPERTIES_PANEL::AfterCommit()
rebuildProperties( selection ); rebuildProperties( selection );
CallAfter( [&]() CallAfter( [this]()
{ {
static_cast<PCB_EDIT_FRAME*>( m_frame )->GetCanvas()->SetFocus(); static_cast<PCB_EDIT_FRAME*>( m_frame )->GetCanvas()->SetFocus();
} ); } );

View File

@ -90,7 +90,10 @@ KIPYTHON_FRAME::KIPYTHON_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, wxT( "KiPython" ), wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, wxT( "KiPython" ),
unityScale ) unityScale )
{ {
CallAfter( [&](){ SetupPythonEditor(); } ); CallAfter( [this]()
{
SetupPythonEditor();
} );
redirectStdio(); redirectStdio();
} }