Fix minor safety and visibility issues

Move onUpdateUI from public to private in EDA_BASE_FRAME since
it is an internal event handler bound via Bind(), not part of
the public API.

Capture the empty-check result before erasing rows in
library_manager.cpp to avoid using invalidated iterators from
the subrange returned by std::ranges::remove_if.

Add null guards to the netHighlightCond toolbar condition
lambda in PCB_EDIT_FRAME to prevent null dereference during
shutdown, matching the pattern used by other toolbar
conditions fixed in f962de966b.
This commit is contained in:
Seth Hillbrand
2026-02-27 19:13:47 -08:00
parent 1e5f0a3d2f
commit 1e2a2fb02c
3 changed files with 17 additions and 5 deletions
+2 -1
View File
@@ -479,9 +479,10 @@ void LIBRARY_MANAGER::LoadGlobalTables( std::initializer_list<LIBRARY_TABLE_TYPE
&& !wxFileName::Exists( path );
} );
bool hadRemovals = !toErase.empty();
table->Rows().erase( toErase.begin(), toErase.end() );
if( !toErase.empty() )
if( hadRemovals )
{
table->Save().map_error(
[]( const LIBRARY_ERROR& aError )
+2 -2
View File
@@ -200,8 +200,6 @@ public:
static void HandleUpdateUIEvent( wxUpdateUIEvent& aEvent, EDA_BASE_FRAME* aFrame,
ACTION_CONDITIONS aCond );
void onUpdateUI( wxUpdateUIEvent& aEvent );
virtual void OnMove( wxMoveEvent& aEvent )
{
aEvent.Skip();
@@ -752,6 +750,8 @@ protected:
DECLARE_EVENT_TABLE()
private:
void onUpdateUI( wxUpdateUIEvent& aEvent );
/**
* (with its unexpected name so it does not collide with the real OnWindowClose()
* function provided in derived classes) is called just before a window
+13 -2
View File
@@ -1119,8 +1119,19 @@ void PCB_EDIT_FRAME::setupUIConditions()
auto netHighlightCond =
[this]( const SELECTION& )
{
KIGFX::RENDER_SETTINGS* settings = GetCanvas()->GetView()->GetPainter()->GetSettings();
return !settings->GetHighlightNetCodes().empty();
if( auto* canvas = GetCanvas() )
{
if( auto* view = canvas->GetView() )
{
if( auto* painter = view->GetPainter() )
{
if( auto* settings = painter->GetSettings() )
return !settings->GetHighlightNetCodes().empty();
}
}
}
return false;
};
auto enableNetHighlightCond =