From 9ac9307b441d14e7604cd4fdd643198b03547266 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Fri, 13 Jun 2014 23:32:50 +0200 Subject: [PATCH] gsdx: try to protect more code when togging f9 deassert gsopen_done before delete the gs object. Compiler and CPU will reordonate the store (or not because it is a global variable). Probably not perfect but better. Got a crash on GSKeyEvent which I guess wasn't thread safe. So let's ensure gs is open. --- plugins/GSdx/GS.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index e23c60d907..979820f37c 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -148,6 +148,8 @@ EXPORT_C_(int) GSinit() EXPORT_C GSshutdown() { + gsopen_done = false; + delete s_gs; s_gs = NULL; @@ -164,12 +166,12 @@ EXPORT_C GSshutdown() } #endif - - gsopen_done = false; } EXPORT_C GSclose() { + gsopen_done = false; + if(s_gs == NULL) return; s_gs->ResetDevice(); @@ -184,8 +186,6 @@ EXPORT_C GSclose() { s_gs->m_wnd->Detach(); } - - gsopen_done = false; } static int _GSopen(void** dsp, char* title, int renderer, int threads = -1) @@ -681,7 +681,8 @@ EXPORT_C GSkeyEvent(GSKeyEventData* e) { try { - s_gs->KeyEvent(e); + if (gsopen_done) + s_gs->KeyEvent(e); } catch (GSDXRecoverableError) {