From 61193dcd13df65638ae690874ec1961d813de025 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 22 Jan 2018 21:15:46 +0100 Subject: [PATCH] Fix assertion failure quitting gerbview Fixes: lp:1744600 https://bugs.launchpad.net/kicad/+bug/1744600 --- gerbview/gerbview_frame.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index f23222bdfa..4de5d109d0 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -280,14 +280,6 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ): GERBVIEW_FRAME::~GERBVIEW_FRAME() { - if( m_toolManager ) - m_toolManager->DeactivateTool(); - - if( auto canvas = GetGalCanvas() ) - { - canvas->GetView()->Clear(); - } - GetGerberLayout()->GetImagesList()->DeleteAllImages(); delete m_gerberLayout; } @@ -295,6 +287,18 @@ GERBVIEW_FRAME::~GERBVIEW_FRAME() void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event ) { + if( m_toolManager ) + m_toolManager->DeactivateTool(); + + if( IsGalCanvasActive() ) + { + GetGalCanvas()->GetView()->Clear(); + // Be sure any OpenGL event cannot be fired after frame deletion: + GetGalCanvas()->SetEvtHandlerEnabled( false ); + } + + GetGalCanvas()->StopDrawing(); + Destroy(); }