Explorar el Código

Don't pass the sentinel event to event callbacks

This is just for internal use and we don't need to incur the overhead of calling callback and watchers for this event.
Sam Lantinga hace 1 año
padre
commit
63979f04c8
Se han modificado 1 ficheros con 2 adiciones y 1 borrados
  1. 2 1
      src/events/SDL_events.c

+ 2 - 1
src/events/SDL_events.c

@@ -1248,7 +1248,8 @@ int SDL_PushEvent(SDL_Event *event)
         event->common.timestamp = SDL_GetTicksNS();
         event->common.timestamp = SDL_GetTicksNS();
     }
     }
 
 
-    if (SDL_EventOK.callback || SDL_event_watchers_count > 0) {
+    if ((SDL_EventOK.callback || SDL_event_watchers_count > 0) &&
+        (event->common.type != SDL_EVENT_POLL_SENTINEL)) {
         SDL_LockMutex(SDL_event_watchers_lock);
         SDL_LockMutex(SDL_event_watchers_lock);
         {
         {
             if (SDL_EventOK.callback && !SDL_EventOK.callback(SDL_EventOK.userdata, event)) {
             if (SDL_EventOK.callback && !SDL_EventOK.callback(SDL_EventOK.userdata, event)) {