Event safety.

Sentry crash probably happens when an update title event fires either
too early or too late to have a simulator or simulator settings.

Sentry issue https://sentry.io/organizations/kicad/issues/3669444623/events/fce0179f7d5e4ff3a7dbb0d90a0570b4/
This commit is contained in:
Jeff Young 2022-12-26 14:37:42 +00:00
parent 424cdf6699
commit 80f3abe082
1 changed files with 17 additions and 14 deletions

View File

@ -322,22 +322,25 @@ void SIM_PLOT_FRAME::initWorkbook()
void SIM_PLOT_FRAME::updateTitle()
{
bool unsaved = true;
bool readOnly = false;
wxString title;
if( m_simulator && m_simulator->Settings() )
{
wxFileName filename = Prj().AbsolutePath( m_simulator->Settings()->GetWorkbookFilename() );
bool readOnly = false;
bool unsaved = false;
if( filename.IsOk() && filename.FileExists() )
{
unsaved = false;
readOnly = !filename.IsFileWritable();
else
unsaved = true;
wxString title;
}
if( m_workbook->IsModified() )
title = wxT( "*" ) + filename.GetName();
else
title = filename.GetName();
}
if( readOnly )
title += wxS( " " ) + _( "[Read Only]" );