From be46977de9d75e296ef78a7f254fa1f7d105694c Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 25 Jan 2016 20:33:04 +1100 Subject: [PATCH] [Glide64] Add critical section in to dlist/config --- Source/Glide64/Config.cpp | 16 +++++----------- Source/Glide64/Main.cpp | 12 +++++++++++- Source/Glide64/rdp.cpp | 12 ++++++++++++ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Source/Glide64/Config.cpp b/Source/Glide64/Config.cpp index 438536777..57dd23ba7 100644 --- a/Source/Glide64/Config.cpp +++ b/Source/Glide64/Config.cpp @@ -49,12 +49,14 @@ #include "Config.h" #ifdef _WIN32 +#include #include #include // begin wxGlade: ::extracode // end wxGlade short Set_basic_mode = 0, Set_texture_dir = 0; +extern CriticalSection * g_ProcessDListCS; ConfigNotebook::ConfigNotebook(wxWindow* parent, int id, const wxPoint& pos, const wxSize& size, long /*style*/) : wxNotebook(parent, id, pos, size, 0) @@ -1072,6 +1074,8 @@ output: none void CALL DllConfig(HWND hParent) { LOG("DllConfig ()\n"); +#ifdef _WIN32 + CGuard guard(*g_ProcessDListCS); ReadSettings(); if (romopen) @@ -1089,7 +1093,6 @@ void CALL DllConfig(HWND hParent) settings.ghq_use = 0; } #endif - //wxThread::Sleep(1000); } else { @@ -1110,18 +1113,9 @@ void CALL DllConfig(HWND hParent) Glide64Config->ShowModal(); delete hostWindow; hostWindow = NULL; +#endif } -/*#ifndef _DEBUG -//#if 1 -#ifndef __GNUG__ -void wxStringData::Free() -{ -free(this); -} -#endif -#endif -*/ void CloseConfig() { if (romopen) diff --git a/Source/Glide64/Main.cpp b/Source/Glide64/Main.cpp index 12711be1c..96384995c 100644 --- a/Source/Glide64/Main.cpp +++ b/Source/Glide64/Main.cpp @@ -41,6 +41,7 @@ #include "Gfx_1.3.h" #include "Version.h" #include +#include #include #include @@ -1184,8 +1185,9 @@ int DllUnload(void) return TRUE; } -#ifdef __WINDOWS__ +#ifdef _WIN32 void wxSetInstance(HINSTANCE hInstance); +CriticalSection * g_ProcessDListCS = NULL; extern "C" int WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, @@ -1197,11 +1199,19 @@ extern "C" int WINAPI DllMain(HINSTANCE hinst, if (fdwReason == DLL_PROCESS_ATTACH) { hinstDLL = hinst; + if (g_ProcessDListCS == NULL) + { + g_ProcessDListCS = new CriticalSection(); + } wxSetInstance(hinstDLL); return DllLoad(); } else if (fdwReason == DLL_PROCESS_DETACH) { + if (g_ProcessDListCS) + { + delete g_ProcessDListCS; + } return DllUnload(); } return TRUE; diff --git a/Source/Glide64/rdp.cpp b/Source/Glide64/rdp.cpp index fdff2ab61..8a824d560 100644 --- a/Source/Glide64/rdp.cpp +++ b/Source/Glide64/rdp.cpp @@ -49,6 +49,12 @@ #include "CRC.h" #include +#ifdef _WIN32 +#include + +extern CriticalSection * g_ProcessDListCS; +#endif + const int NumOfFormats = 3; SCREEN_SHOT_FORMAT ScreenShotFormats[NumOfFormats] = { { "BMP", "bmp", wxBITMAP_TYPE_BMP }, { "PNG", "png", wxBITMAP_TYPE_PNG }, { "JPEG", "jpeg", wxBITMAP_TYPE_JPEG } }; @@ -564,6 +570,9 @@ int depth_buffer_fog; EXPORT void CALL ProcessDList(void) { +#ifdef _WIN32 + CGuard guard(*g_ProcessDListCS); +#endif no_dlist = false; update_screen_count = 0; ChangeSize(); @@ -4102,6 +4111,9 @@ output: none *******************************************************************/ void CALL ProcessRDPList(void) { +#ifdef _WIN32 + CGuard guard(*g_ProcessDListCS); +#endif LOG("ProcessRDPList ()\n"); LRDP("ProcessRDPList ()\n");