Просмотр исходного кода

Fixed some Wayland cursor related thread-safety warnings

Sam Lantinga 20 часов назад
Родитель
Сommit
64def01534
1 измененных файлов с 8 добавлено и 5 удалено
  1. 8 5
      src/video/wayland/SDL_waylandmouse.c

+ 8 - 5
src/video/wayland/SDL_waylandmouse.c

@@ -565,18 +565,21 @@ void Wayland_CursorStateDestroyFrameCallback(SDL_WaylandCursorState *state)
     SDL_UnlockMutex(cursor_thread_context.lock);
     SDL_UnlockMutex(cursor_thread_context.lock);
 }
 }
 
 
-static void Wayland_CursorStateResetAnimation(SDL_WaylandCursorState *state, bool lock)
+static void Wayland_CursorStateResetAnimationState(SDL_WaylandCursorState *state)
 {
 {
-    if (lock) {
-        SDL_LockMutex(cursor_thread_context.lock);
-    }
-
     state->last_frame_callback_time_ms = SDL_GetTicks();
     state->last_frame_callback_time_ms = SDL_GetTicks();
     state->current_frame_time_ms = 0;
     state->current_frame_time_ms = 0;
     state->current_frame = 0;
     state->current_frame = 0;
+}
 
 
+static void Wayland_CursorStateResetAnimation(SDL_WaylandCursorState *state, bool lock)
+{
     if (lock) {
     if (lock) {
+        SDL_LockMutex(cursor_thread_context.lock);
+        Wayland_CursorStateResetAnimationState(state);
         SDL_UnlockMutex(cursor_thread_context.lock);
         SDL_UnlockMutex(cursor_thread_context.lock);
+    } else {
+        Wayland_CursorStateResetAnimationState(state);
     }
     }
 }
 }