From 408e225048b8613e619bace316a86ae03a02a5be Mon Sep 17 00:00:00 2001 From: James Rowe Date: Sun, 15 Dec 2019 16:20:59 -0700 Subject: [PATCH] Destroy GLWindow on exit to prevent issues closing the app while in fullscreen --- src/citra_qt/bootmanager.cpp | 14 +++++++++----- src/citra_qt/bootmanager.h | 3 +++ src/citra_qt/main.cpp | 3 +++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 11d49dd50..a9cdddc18 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -359,11 +359,7 @@ void GRenderWindow::resizeEvent(QResizeEvent* event) { } void GRenderWindow::InitRenderTarget() { - // Destroy the previous run's child_widget which should also destroy the child_window - if (child_widget) { - layout()->removeWidget(child_widget); - delete child_widget; - } + ReleaseRenderTarget(); GMainWindow* parent = GetMainWindow(); QWindow* parent_win_handle = parent ? parent->windowHandle() : nullptr; @@ -379,6 +375,14 @@ void GRenderWindow::InitRenderTarget() { BackupGeometry(); } +void GRenderWindow::ReleaseRenderTarget() { + if (child_widget) { + layout()->removeWidget(child_widget); + delete child_widget; + child_widget = nullptr; + } +} + void GRenderWindow::CaptureScreenshot(u32 res_scale, const QString& screenshot_path) { if (res_scale == 0) res_scale = VideoCore::GetResolutionScaleFactor(); diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h index 2a8b32bff..922e093f9 100644 --- a/src/citra_qt/bootmanager.h +++ b/src/citra_qt/bootmanager.h @@ -173,6 +173,9 @@ public: void InitRenderTarget(); + /// Destroy the previous run's child_widget which should also destroy the child_window + void ReleaseRenderTarget(); + void CaptureScreenshot(u32 res_scale, const QString& screenshot_path); public slots: diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index bbe4a94f2..dd56f4b13 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -1019,6 +1019,9 @@ void GMainWindow::ShutdownGame() { UpdateWindowTitle(); game_path.clear(); + + // When closing the game, destroy the GLWindow to clear the context after the game is closed + render_window->ReleaseRenderTarget(); } void GMainWindow::StoreRecentFile(const QString& filename) {