From bf422479711afc196a89bf2e6ab236a0b78ac5e6 Mon Sep 17 00:00:00 2001 From: John Beard Date: Wed, 31 Oct 2018 19:36:06 +0100 Subject: [PATCH] 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 --- eeschema/sch_draw_panel.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/eeschema/sch_draw_panel.cpp b/eeschema/sch_draw_panel.cpp index ccf2edf6cd..f88c7e17ff 100644 --- a/eeschema/sch_draw_panel.cpp +++ b/eeschema/sch_draw_panel.cpp @@ -682,8 +682,14 @@ void SCH_DRAW_PANEL::onPaint( wxPaintEvent& aEvent ) // (depending on platforms). Do nothing in this case return; + SCH_SCREEN* screen = static_cast( 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: - static_cast( GetScreen() )->UpdateSymbolLinks(); + screen->UpdateSymbolLinks(); if( m_painter ) static_cast(m_painter.get())->GetSettings()->ImportLegacyColors( nullptr );