From 5adb26a169cedb57830c29b4dbf9512490a076f6 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 14 Jul 2003 06:21:12 +0000 Subject: [PATCH] thread safety --- stepmania/src/InputFilter.cpp | 14 ++++++++++++-- stepmania/src/InputFilter.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/stepmania/src/InputFilter.cpp b/stepmania/src/InputFilter.cpp index 523ef496f6..6bc8d027bc 100644 --- a/stepmania/src/InputFilter.cpp +++ b/stepmania/src/InputFilter.cpp @@ -37,6 +37,8 @@ void InputFilter::ButtonPressed( DeviceInput di, bool Down ) m_fSecsHeld[di.device][di.button] = 0; InputEventType iet = Down? IET_FIRST_PRESS:IET_RELEASE; + + LockMut(queuemutex); queue.push_back( InputEvent(di,iet) ); } @@ -51,6 +53,10 @@ void InputFilter::Update(float fDeltaTime) { INPUTMAN->Update( fDeltaTime ); + /* Make sure that nothing gets inserted while we do this, to prevent + * things like "key pressed, key release, key repeat". */ + LockMut(queuemutex); + for( int d=0; d