win32: Don't return existing display from gdk_display_open()

Existing code assumes displays are new connections and calls
gdk_display_close() on the display when done with whatever it was
doing.

If we return an existing display, that display gets closed...

It's also what the other backends do, including MacOS.

Fixes gsk/misc test.
This commit is contained in:
Benjamin Otte 2024-10-28 00:59:44 +01:00
parent 2f1c42d095
commit e7c6e45701

View File

@ -527,18 +527,16 @@ _gdk_win32_display_open (const char *display_name)
GDK_NOTE (MISC, g_print ("gdk_display_open: %s\n", (display_name ? display_name : "NULL")));
if (display_name == NULL || g_ascii_strcasecmp (display_name, gdk_display_get_name (display)) == 0)
if (display != NULL)
{
if (display != NULL)
{
GDK_NOTE (MISC, g_print ("... return existing gdkdisplay\n"));
return display;
}
GDK_NOTE (MISC, g_print ("... Display is already open\n"));
return NULL;
}
else
if (display_name != NULL)
{
/* we don't really support multiple GdkDisplay's on Windows at this point */
GDK_NOTE (MISC, g_print ("... return NULL\n"));
GDK_NOTE (MISC, g_print ("... win32 does not support named displays, but given name was \"%s\"\n", display_name));
return NULL;
}