From 21725eeef33be8c7b63346fcb76435f29f70bdd2 Mon Sep 17 00:00:00 2001
From: jean-pierre charras <jp.charras@wanadoo.fr>
Date: Thu, 20 Mar 2025 10:12:59 +0100
Subject: [PATCH] ~EDA_DRAW_PANEL_GAL(): Fix crash: ensure a onShowEvent is not
 fired.

Due to changes in EDA_DRAW_PANEL_GAL (a wxEVT_SHOW event was added) when
destroyed a dialog using it (namely the PAD editor) a wxEVT_SHOW event was fired
during Dtor process (at least on Windows). It is now disabled in Dtor.
---
 common/draw_panel_gal.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp
index c626dc9569..0ac9a79db9 100644
--- a/common/draw_panel_gal.cpp
+++ b/common/draw_panel_gal.cpp
@@ -166,6 +166,8 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
 
 EDA_DRAW_PANEL_GAL::~EDA_DRAW_PANEL_GAL()
 {
+    // Ensure EDA_DRAW_PANEL_GAL::onShowEvent is not fired during Dtor process
+    Disconnect( wxEVT_SHOW, wxShowEventHandler( EDA_DRAW_PANEL_GAL::onShowEvent ) );
     StopDrawing();
 
     wxASSERT( !m_drawing );
@@ -173,6 +175,7 @@ EDA_DRAW_PANEL_GAL::~EDA_DRAW_PANEL_GAL()
     delete m_viewControls;
     delete m_view;
     delete m_gal;
+    m_gal = nullptr;    // Ensure OnShow is not called
 }