From 9d40374baff216b5dbe18438d2948bc3915ebf0a Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 14 Feb 2024 18:15:49 +0000 Subject: [PATCH] Don't capture references to local variables for CallAfter. Fixes https://gitlab.com/kicad/code/kicad/-/issues/16934 --- common/eda_base_frame.cpp | 2 +- common/widgets/properties_panel.cpp | 2 +- common/widgets/search_pane_tab.cpp | 6 ++++-- common/widgets/widget_hotkey_list.cpp | 2 +- cvpcb/display_footprints_frame.cpp | 2 +- eeschema/widgets/sch_properties_panel.cpp | 2 +- gerbview/gerbview_frame.cpp | 2 +- kicad/update_manager.cpp | 11 +++++++---- pagelayout_editor/pl_editor_frame.cpp | 2 +- pcbnew/footprint_edit_frame.cpp | 2 +- pcbnew/pcb_edit_frame.cpp | 4 ++-- pcbnew/widgets/appearance_controls.cpp | 2 +- pcbnew/widgets/pcb_properties_panel.cpp | 2 +- scripting/kipython_frame.cpp | 5 ++++- 14 files changed, 27 insertions(+), 19 deletions(-) diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index c5f6a5d247..42b69ec2ef 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -483,7 +483,7 @@ void EDA_BASE_FRAME::ReCreateMenuBar() * ensure that they do not occur within the same event handling call stack. */ - CallAfter( [&]() + CallAfter( [this]() { if( !m_isClosing ) doReCreateMenuBar(); diff --git a/common/widgets/properties_panel.cpp b/common/widgets/properties_panel.cpp index e94b4e621c..90bef94a26 100644 --- a/common/widgets/properties_panel.cpp +++ b/common/widgets/properties_panel.cpp @@ -133,7 +133,7 @@ PROPERTIES_PANEL::PROPERTIES_PANEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame ) Bind( wxEVT_SIZE, [&]( wxSizeEvent& aEvent ) { - CallAfter( [&]() + CallAfter( [this]() { RecalculateSplitterPos(); } ); diff --git a/common/widgets/search_pane_tab.cpp b/common/widgets/search_pane_tab.cpp index 300e63d409..57481e63f6 100644 --- a/common/widgets/search_pane_tab.cpp +++ b/common/widgets/search_pane_tab.cpp @@ -80,10 +80,12 @@ void SEARCH_PANE_LISTVIEW::GetSelectRowsList( std::vector& aSelectedList ) void SEARCH_PANE_LISTVIEW::OnItemActivated( wxListEvent& aEvent ) { + long item = aEvent.GetIndex(); + CallAfter( - [&]() + [this, item]() { - m_handler->ActivateItem( aEvent.GetIndex() ); + m_handler->ActivateItem( item ); } ); m_selectionDirty = true; diff --git a/common/widgets/widget_hotkey_list.cpp b/common/widgets/widget_hotkey_list.cpp index d2c5ad3502..9c1120c88f 100644 --- a/common/widgets/widget_hotkey_list.cpp +++ b/common/widgets/widget_hotkey_list.cpp @@ -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( 3 )->SetMinWidth( aParent->GetTextExtent( command_header ).x * 5 + pad ); - CallAfter( [&]() + CallAfter( [this]() { GetDataView()->Update(); } ); diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index 7c460b8547..5c4cf51da3 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -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 // 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 UpdateToolbarControlSizes(); diff --git a/eeschema/widgets/sch_properties_panel.cpp b/eeschema/widgets/sch_properties_panel.cpp index a15b2c7cdb..c0320b92c2 100644 --- a/eeschema/widgets/sch_properties_panel.cpp +++ b/eeschema/widgets/sch_properties_panel.cpp @@ -116,7 +116,7 @@ void SCH_PROPERTIES_PANEL::AfterCommit() rebuildProperties( selection ); - CallAfter( [&]() + CallAfter( [this]() { m_frame->GetCanvas()->SetFocus(); } ); diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 9b5923eb66..2149b82135 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -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 // 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 UpdateToolbarControlSizes(); diff --git a/kicad/update_manager.cpp b/kicad/update_manager.cpp index d7e1d08634..42a8dc0f29 100644 --- a/kicad/update_manager.cpp +++ b/kicad/update_manager.cpp @@ -226,11 +226,12 @@ void UPDATE_MANAGER::CheckForUpdate( wxWindow* aNoticeParent ) if( response.version != settings->m_lastReceivedUpdate ) { aNoticeParent->CallAfter( - [&]() + [aNoticeParent, response]() { - auto notice = new DIALOG_UPDATE_NOTICE( - aNoticeParent, response.version, response.details_url, - response.downloads_url ); + auto notice = new DIALOG_UPDATE_NOTICE( aNoticeParent, + response.version, + response.details_url, + response.downloads_url ); int retCode = notice->ShowModal(); @@ -238,6 +239,8 @@ void UPDATE_MANAGER::CheckForUpdate( wxWindow* aNoticeParent ) { // basically saving the last received update prevents us from // prompting again + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + KICAD_SETTINGS* settings = mgr.GetAppSettings(); settings->m_lastReceivedUpdate = response.version; } } ); diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index b02d9815c5..b6711b118f 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -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 // 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 UpdateToolbarControlSizes(); diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index b8d23fa124..51a70e701a 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -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 // it seems to require some sizes calculated that aren't yet (at least on GTK). CallAfter( - [&]() + [this]() { // Ensure the controls on the toolbars all are correctly sized UpdateToolbarControlSizes(); diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 78ef6c9a81..f508807a03 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -451,7 +451,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : #ifdef __WXMAC__ if( Kiface().IsSingle() ) { - CallAfter( [&]() + CallAfter( [this]() { 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 // 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 UpdateToolbarControlSizes(); diff --git a/pcbnew/widgets/appearance_controls.cpp b/pcbnew/widgets/appearance_controls.cpp index 47ae10d554..1a94c8254f 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -994,7 +994,7 @@ void APPEARANCE_CONTROLS::OnNetGridMouseEvent( wxMouseEvent& aEvent ) else if( aEvent.Dragging() ) { // not allowed - CallAfter( [&]() + CallAfter( [this]() { m_netsGrid->ClearSelection(); } ); diff --git a/pcbnew/widgets/pcb_properties_panel.cpp b/pcbnew/widgets/pcb_properties_panel.cpp index b33ea74cb0..3816b0d658 100644 --- a/pcbnew/widgets/pcb_properties_panel.cpp +++ b/pcbnew/widgets/pcb_properties_panel.cpp @@ -122,7 +122,7 @@ void PCB_PROPERTIES_PANEL::AfterCommit() rebuildProperties( selection ); - CallAfter( [&]() + CallAfter( [this]() { static_cast( m_frame )->GetCanvas()->SetFocus(); } ); diff --git a/scripting/kipython_frame.cpp b/scripting/kipython_frame.cpp index 96c1d3e59b..94e4fe7189 100644 --- a/scripting/kipython_frame.cpp +++ b/scripting/kipython_frame.cpp @@ -90,7 +90,10 @@ KIPYTHON_FRAME::KIPYTHON_FRAME( KIWAY* aKiway, wxWindow* aParent ) : wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, wxT( "KiPython" ), unityScale ) { - CallAfter( [&](){ SetupPythonEditor(); } ); + CallAfter( [this]() + { + SetupPythonEditor(); + } ); redirectStdio(); }