From 7e67ec6399e08656695498245e7e61dd9297e4e2 Mon Sep 17 00:00:00 2001 From: Vladimir Olteanu Date: Sat, 17 Jul 2021 13:49:41 +0300 Subject: [PATCH] SdlMutex: error checking --- Source/utils/sdl_mutex.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Source/utils/sdl_mutex.h b/Source/utils/sdl_mutex.h index e228167d9..2f37c730c 100644 --- a/Source/utils/sdl_mutex.h +++ b/Source/utils/sdl_mutex.h @@ -34,19 +34,26 @@ public: void lock() noexcept // NOLINT(readability-identifier-naming) { - SDL_LockMutex(mutex_); + int err = SDL_LockMutex(mutex_); + if (err == -1) + ErrSdl(); } #if SDL_VERSION_ATLEAST(2, 0, 0) bool try_lock() noexcept // NOLINT(readability-identifier-naming) { - return SDL_TryLockMutex(mutex_) == 0; + int err = SDL_TryLockMutex(mutex_); + if (err == -1) + ErrSdl(); + return err == 0; } #endif void unlock() noexcept // NOLINT(readability-identifier-naming) { - SDL_UnlockMutex(mutex_); + int err = SDL_UnlockMutex(mutex_); + if (err == -1) + ErrSdl(); } private: