From d8eda06a5a598332e032b468599e71be66d8aeed Mon Sep 17 00:00:00 2001 From: fonsinchen Date: Sun, 23 Feb 2014 14:16:36 +0000 Subject: (svn r26366) -Fix: Protect the windows video driver from concurrent access (frosch123) --- src/video/win32_v.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 78a24b407..362b0ac1f 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -1326,27 +1326,38 @@ void VideoDriver_Win32::MainLoop() bool VideoDriver_Win32::ChangeResolution(int w, int h) { + if (_draw_mutex != NULL) _draw_mutex->BeginCritical(true); if (_window_maximize) ShowWindow(_wnd.main_wnd, SW_SHOWNORMAL); _wnd.width = _wnd.width_org = w; _wnd.height = _wnd.height_org = h; - return this->MakeWindow(_fullscreen); // _wnd.fullscreen screws up ingame resolution switching + bool ret = this->MakeWindow(_fullscreen); // _wnd.fullscreen screws up ingame resolution switching + if (_draw_mutex != NULL) _draw_mutex->EndCritical(true); + return ret; } bool VideoDriver_Win32::ToggleFullscreen(bool full_screen) { - return this->MakeWindow(full_screen); + if (_draw_mutex != NULL) _draw_mutex->BeginCritical(true); + bool ret = this->MakeWindow(full_screen); + if (_draw_mutex != NULL) _draw_mutex->EndCritical(true); + return ret; } bool VideoDriver_Win32::AfterBlitterChange() { - return AllocateDibSection(_screen.width, _screen.height, true) && this->MakeWindow(_fullscreen); + if (_draw_mutex != NULL) _draw_mutex->BeginCritical(true); + bool ret = AllocateDibSection(_screen.width, _screen.height, true) && this->MakeWindow(_fullscreen); + if (_draw_mutex != NULL) _draw_mutex->EndCritical(true); + return ret; } void VideoDriver_Win32::EditBoxLostFocus() { + if (_draw_mutex != NULL) _draw_mutex->BeginCritical(true); CancelIMEComposition(_wnd.main_wnd); SetCompositionPos(_wnd.main_wnd); SetCandidatePos(_wnd.main_wnd); + if (_draw_mutex != NULL) _draw_mutex->EndCritical(true); } -- cgit v1.2.3-54-g00ecf