summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfonsinchen <fonsinchen@openttd.org>2014-02-23 14:16:36 +0000
committerfonsinchen <fonsinchen@openttd.org>2014-02-23 14:16:36 +0000
commitd8eda06a5a598332e032b468599e71be66d8aeed (patch)
treeb49f31d80385de8e91a79b62e32c0679776185d7 /src
parentb4a015a4bd37991e3ce413946fe63652443a8d73 (diff)
downloadopenttd-d8eda06a5a598332e032b468599e71be66d8aeed.tar.xz
(svn r26366) -Fix: Protect the windows video driver from concurrent access (frosch123)
Diffstat (limited to 'src')
-rw-r--r--src/video/win32_v.cpp17
1 files 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);
}