From e018c1c41adc9033ca554d6d89851514b4b09a18 Mon Sep 17 00:00:00 2001 From: Andy Vandijck Date: Mon, 7 Jul 2025 12:44:50 +0200 Subject: [PATCH] Fix D3D window close Fix D3D window close --- src/wx/panel.cpp | 12 +++++++++++- src/wx/wxvbam.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/wx/panel.cpp b/src/wx/panel.cpp index db34c410..d5fd4401 100644 --- a/src/wx/panel.cpp +++ b/src/wx/panel.cpp @@ -1254,8 +1254,10 @@ void GameArea::OnIdle(wxIdleEvent& event) w = panel->GetWindow(); - if (panel->d3dframe != NULL) + if (panel->d3dframe != NULL) { panel->d3dframe->Bind(VBAM_EVT_USER_INPUT, &GameArea::OnUserInput, this); + panel->d3dframe->Bind(wxEVT_CLOSE_WINDOW, &GameArea::OnD3DClose, this); + } // set up event handlers w->Bind(VBAM_EVT_USER_INPUT, &GameArea::OnUserInput, this); @@ -1410,6 +1412,14 @@ static Display* GetX11Display() { } #endif // __WXGTK__ +void GameArea::OnD3DClose(wxCloseEvent& ev) +{ + (void)ev; + + delete panel->d3dframe; + panel->d3dframe = NULL; +} + void GameArea::OnUserInput(widgets::UserInputEvent& event) { bool emulated_key_pressed = false; for (const auto& event_data : event.data()) { diff --git a/src/wx/wxvbam.h b/src/wx/wxvbam.h index 999219d0..76b96c4a 100644 --- a/src/wx/wxvbam.h +++ b/src/wx/wxvbam.h @@ -546,6 +546,7 @@ protected: void EraseBackground(wxEraseEvent& ev); void OnSize(wxSizeEvent& ev); void OnKillFocus(wxFocusEvent& ev); + void OnD3DClose(wxCloseEvent& ev); #ifndef NO_FFMPEG recording::MediaRecorder snd_rec, vid_rec;