wayland: Try to detach at the beginning of ShowWindow, just in case.

It's possible that an external component (probably a GL/VK context) committed, so we need to cover our bases and detach in both HideWindow and ShowWindow.

Fixes a crash in UE5 editor's pop-ups.
This commit is contained in:
Ethan Lee 2022-04-06 01:18:03 -04:00 committed by GitHub
parent dcfb7fff00
commit 3ada694e62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -995,6 +995,21 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
SDL_VideoData *c = _this->driverdata;
SDL_WindowData *data = window->driverdata;
/* Detach any previous buffers before resetting everything, otherwise when
* calling this a second time you'll get an annoying protocol error!
*
* FIXME: This was originally moved to HideWindow, which _should_ make
* sense, but for whatever reason UE5's popups require that this actually
* be in both places at once? Possibly from renderers making commits? I can't
* fully remember if this location caused crashes or if I was fixing a pair
* of Hide/Show calls. In any case, UE gives us a pretty good test and having
* both detach calls passes.
*
* -flibit
*/
wl_surface_attach(data->surface, NULL, 0, 0);
wl_surface_commit(data->surface);
/* Create the shell surface and map the toplevel */
#ifdef HAVE_LIBDECOR_H
if (c->shell.libdecor) {