macos: push to head of awaiting frames
authorChristian Hergert <christian@hergert.me>
Sun, 30 Jan 2022 01:05:48 +0000 (17:05 -0800)
committerChristian Hergert <christian@hergert.me>
Fri, 4 Feb 2022 03:26:16 +0000 (19:26 -0800)
Always add to the head of awaiting frames as the list is processed
in the opposite direction.

gdk/macos/gdkmacosdisplay.c

index 051a92190353ac62cdcba889308950046f5deeee..9507d65c883c3d4531fbbe8c0f4ddaad0479e2e3 100644 (file)
@@ -987,7 +987,11 @@ _gdk_macos_display_add_frame_callback (GdkMacosDisplay *self,
 
   if (!queue_contains (&self->awaiting_frames, &surface->frame))
     {
-      g_queue_push_tail_link (&self->awaiting_frames, &surface->frame);
+      /* Processing frames is always head to tail, so push to the
+       * head so that we don't possibly re-enter this right after
+       * adding to the queue.
+       */
+      g_queue_push_head_link (&self->awaiting_frames, &surface->frame);
 
       if (self->awaiting_frames.length == 1)
         gdk_display_link_source_unpause ((GdkDisplayLinkSource *)self->frame_source);