Don't presume a selection (potentially KICAD-8VP).

This commit is contained in:
Jeff Young 2025-07-11 20:49:31 +01:00
parent fc0bcdc8a3
commit 34367020c4

View File

@ -282,8 +282,11 @@ void PANEL_COLOR_SETTINGS::createSwatch( int aLayer, const wxString& aName )
void PANEL_COLOR_SETTINGS::ShowColorContextMenu( wxMouseEvent& aEvent, int aLayer )
{
auto selected =
static_cast<COLOR_SETTINGS*>( m_cbTheme->GetClientData( m_cbTheme->GetSelection() ) );
int themeSel = m_cbTheme->GetSelection();
if( themeSel >= 0 )
{
COLOR_SETTINGS* selected = static_cast<COLOR_SETTINGS*>( m_cbTheme->GetClientData( themeSel ) );
wxCHECK_RET( selected, wxT( "Invalid color theme selected" ) );
@ -299,8 +302,7 @@ void PANEL_COLOR_SETTINGS::ShowColorContextMenu( wxMouseEvent& aEvent, int aLaye
KIUI::AddMenuItem( &menu, ID_PASTE, _( "Paste color" ), KiBitmap( BITMAPS::paste ) );
if( !readOnly && current != saved )
KIUI::AddMenuItem( &menu, ID_REVERT, _( "Revert to saved color" ),
KiBitmap( BITMAPS::undo ) );
KIUI::AddMenuItem( &menu, ID_REVERT, _( "Revert to saved color" ), KiBitmap( BITMAPS::undo ) );
menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
[&]( wxCommandEvent& aCmd )
@ -325,6 +327,7 @@ void PANEL_COLOR_SETTINGS::ShowColorContextMenu( wxMouseEvent& aEvent, int aLaye
} );
PopupMenu( &menu );
}
}