Eeschema: fix potential crash when closing Kicad app.

The crash happens when a wxPaint event is fired after deleting the schematic frame.
It happened only on one Linux install.

Fixes: lp:1800874
* https://bugs.launchpad.net/kicad/+bug/1800874
This commit is contained in:
John Beard 2018-10-31 19:36:06 +01:00 committed by jean-pierre charras
parent 08814b0512
commit bf42247971
1 changed files with 7 additions and 1 deletions

View File

@ -682,8 +682,14 @@ void SCH_DRAW_PANEL::onPaint( wxPaintEvent& aEvent )
// (depending on platforms). Do nothing in this case // (depending on platforms). Do nothing in this case
return; return;
SCH_SCREEN* screen = static_cast<SCH_SCREEN*>( GetScreen() );
// The screen might be null if the wxPaintEvent is fired after the parent frame deletion
if( !screen )
return;
// Ensure links are up to date, even if a library was reloaded for some reason: // Ensure links are up to date, even if a library was reloaded for some reason:
static_cast<SCH_SCREEN*>( GetScreen() )->UpdateSymbolLinks(); screen->UpdateSymbolLinks();
if( m_painter ) if( m_painter )
static_cast<KIGFX::SCH_PAINTER*>(m_painter.get())->GetSettings()->ImportLegacyColors( nullptr ); static_cast<KIGFX::SCH_PAINTER*>(m_painter.get())->GetSettings()->ImportLegacyColors( nullptr );