From 80f3abe082d627ba5de87f2fce5d3d234ec8d4ff Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 26 Dec 2022 14:37:42 +0000 Subject: [PATCH] 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/ --- eeschema/sim/sim_plot_frame.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index 5679b6a267..19ce86ac65 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -322,22 +322,25 @@ void SIM_PLOT_FRAME::initWorkbook() void SIM_PLOT_FRAME::updateTitle() { - wxFileName filename = Prj().AbsolutePath( m_simulator->Settings()->GetWorkbookFilename() ); - - bool readOnly = false; - bool unsaved = false; - - if( filename.IsOk() && filename.FileExists() ) - readOnly = !filename.IsFileWritable(); - else - unsaved = true; - + bool unsaved = true; + bool readOnly = false; wxString title; - if( m_workbook->IsModified() ) - title = wxT( "*" ) + filename.GetName(); - else - title = filename.GetName(); + if( m_simulator && m_simulator->Settings() ) + { + wxFileName filename = Prj().AbsolutePath( m_simulator->Settings()->GetWorkbookFilename() ); + + if( filename.IsOk() && filename.FileExists() ) + { + unsaved = false; + readOnly = !filename.IsFileWritable(); + } + + if( m_workbook->IsModified() ) + title = wxT( "*" ) + filename.GetName(); + else + title = filename.GetName(); + } if( readOnly ) title += wxS( " " ) + _( "[Read Only]" );