From a85a88e112f8d920bf442db1454892cb194743fe Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 10 Feb 2018 16:23:05 -0800 Subject: [PATCH] SDL: Apply shutdown race condition fix. --- Qt/QtMain.cpp | 1 + Qt/QtMain.h | 5 +++++ SDL/SDLGLGraphicsContext.h | 5 +++++ SDL/SDLMain.cpp | 1 + 4 files changed, 12 insertions(+) diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index c9a9ac53a..a2596d136 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -208,6 +208,7 @@ void MainUI::EmuThreadFunc() { emuThreadState = (int)EmuThreadState::STOPPED; NativeShutdownGraphics(); + graphicsContext->StopThread(); } void MainUI::EmuThreadStart() { diff --git a/Qt/QtMain.h b/Qt/QtMain.h index 404e50439..191dd320e 100644 --- a/Qt/QtMain.h +++ b/Qt/QtMain.h @@ -82,6 +82,11 @@ public: renderManager_->ThreadEnd(); } + void StopThread() override { + renderManager_->WaitUntilQueueIdle(); + renderManager_->StopThread(); + } + private: Draw::DrawContext *draw_ = nullptr; GLRenderManager *renderManager_ = nullptr; diff --git a/SDL/SDLGLGraphicsContext.h b/SDL/SDLGLGraphicsContext.h index 52ea68f01..2695ebf64 100644 --- a/SDL/SDLGLGraphicsContext.h +++ b/SDL/SDLGLGraphicsContext.h @@ -38,6 +38,11 @@ public: renderManager_->ThreadEnd(); } + void StopThread() override { + renderManager_->WaitUntilQueueIdle(); + renderManager_->StopThread(); + } + private: Draw::DrawContext *draw_ = nullptr; SDL_Window *window_; diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index bbf4b42e2..bdc6c6d97 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -423,6 +423,7 @@ static void EmuThreadFunc(GraphicsContext *graphicsContext) { emuThreadState = (int)EmuThreadState::STOPPED; NativeShutdownGraphics(); + graphicsContext->StopThread(); } static void EmuThreadStart(GraphicsContext *context) {