Destroy GLWindow on exit to prevent issues closing the app while in fullscreen

This commit is contained in:
James Rowe 2019-12-15 16:20:59 -07:00
parent 36c5058d66
commit 408e225048
3 changed files with 15 additions and 5 deletions

View file

@ -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();

View file

@ -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:

View file

@ -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) {