Fix MRU logic errors.

The most serious was that we were keeping a reference to a string
which changed out from under the reference when it was deleted from
the wxArrayString.

Fixes https://gitlab.com/kicad/code/kicad/issues/12770
This commit is contained in:
Jeff Young 2022-10-27 14:25:41 +01:00
parent f6c441c434
commit 757c33ea13
1 changed files with 7 additions and 7 deletions

View File

@ -486,6 +486,12 @@ void EDA_3D_VIEWER_FRAME::applyViewport( const wxString& aViewportName )
m_canvas->Request_refresh();
else
m_canvas->RenderRaytracingRequest();
if( !m_lastSelectedViewport->name.IsEmpty() )
{
m_viewportMRU.Remove( m_lastSelectedViewport->name );
m_viewportMRU.Insert( m_lastSelectedViewport->name, 0 );
}
}
else
{
@ -500,19 +506,13 @@ void EDA_3D_VIEWER_FRAME::onViewportChanged( wxCommandEvent& aEvent )
int count = m_cbViewports->GetCount();
int index = m_cbViewports->GetSelection();
if( index >= 0 && index < count - 3 )
if( index >= 0 && index < count - 3 /* separator */ )
{
VIEWPORT3D* viewport = static_cast<VIEWPORT3D*>( m_cbViewports->GetClientData( index ) );
wxCHECK( viewport, /* void */ );
applyViewport( viewport->name );
if( !viewport->name.IsEmpty() )
{
m_viewportMRU.Remove( viewport->name );
m_viewportMRU.Insert( viewport->name, 0 );
}
}
else if( index == count - 2 )
{