gtkmain: short-circuit gtk_main_sync() where no display
authorChristian Hergert <chergert@redhat.com>
Fri, 10 Jan 2020 23:00:10 +0000 (15:00 -0800)
committerChristian Hergert <chergert@redhat.com>
Fri, 10 Jan 2020 23:00:10 +0000 (15:00 -0800)
If there is no display, we will hit the slow path here which
can introduce long latencies in unit tests. This checks for
a NULL list of displays and simply short-circuits.

gtk/gtkmain.c

index fe5868a95d7738522161a9bcb8844c0e8580c0b7..93fea8540ae4367f868fe4c8f5746661627c5d37 100644 (file)
@@ -1081,6 +1081,9 @@ gtk_main_sync (void)
   
   /* Try storing all clipboard data we have */
   displays = gdk_display_manager_list_displays (gdk_display_manager_get ());
+  if (displays == NULL)
+    return;
+
   cancel = g_cancellable_new ();
 
   for (l = displays; l; l = l->next)