diff options
author | Johannes Schickel | 2012-04-01 23:36:51 +0200 |
---|---|---|
committer | Johannes Schickel | 2012-04-02 00:03:28 +0200 |
commit | 6626258e0f8330cf21be63763b8fb2ba7b02a113 (patch) | |
tree | 38c9f79b577c152b0b623b638c2f6968ffe1f518 | |
parent | d27d8cec8304d4ab85238333825bd2b9a01e5f8c (diff) | |
download | scummvm-rg350-6626258e0f8330cf21be63763b8fb2ba7b02a113.tar.gz scummvm-rg350-6626258e0f8330cf21be63763b8fb2ba7b02a113.tar.bz2 scummvm-rg350-6626258e0f8330cf21be63763b8fb2ba7b02a113.zip |
IPHONE: Protect access to the event list via a mutex.
-rw-r--r-- | backends/platform/iphone/iphone_video.h | 1 | ||||
-rw-r--r-- | backends/platform/iphone/iphone_video.mm | 11 |
2 files changed, 11 insertions, 1 deletions
diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index d1ee47489d..0c70b1fe97 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -48,6 +48,7 @@ struct InternalEvent { VideoContext _videoContext; Common::List<InternalEvent> _events; + NSLock *_eventLock; SoftKeyboard *_keyboardView; EAGLContext *_context; diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 25515ed7c0..1984c7c36f 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -66,15 +66,19 @@ void iPhone_updateScreen() { } bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY) { + [g_iPhoneViewInstance->_eventLock lock]; Common::List<InternalEvent> &events = g_iPhoneViewInstance->_events; - if (events.empty()) + if (events.empty()) { + [g_iPhoneViewInstance->_eventLock unlock]; return false; + } const InternalEvent &front = *events.begin(); *outEvent = front.type; *outX = front.value1; *outY = front.value2; events.pop_front(); + [g_iPhoneViewInstance->_eventLock unlock]; return true; } @@ -191,6 +195,8 @@ const char *iPhone_getDocumentsDir() { _firstTouch = NULL; _secondTouch = NULL; + _eventLock = [[NSLock alloc] init]; + _gameScreenVertCoords[0] = _gameScreenVertCoords[1] = _gameScreenVertCoords[2] = _gameScreenVertCoords[3] = _gameScreenVertCoords[4] = _gameScreenVertCoords[5] = @@ -236,6 +242,7 @@ const char *iPhone_getDocumentsDir() { _videoContext.overlayTexture.free(); _videoContext.mouseTexture.free(); + [_eventLock dealloc]; [super dealloc]; } @@ -570,7 +577,9 @@ const char *iPhone_getDocumentsDir() { } - (void)addEvent:(InternalEvent)event { + [_eventLock lock]; _events.push_back(event); + [_eventLock unlock]; } /** |