window: Fix crash when unexporting unrealized window

It is possible that the window gets unrealized while a handle to its
surface is exported. This, naturally, invalidates the handle, so there
is nothing left to unexport. We should just note that and do nothing,
rather than crashing.

Fixes a crash when a portal-backed file dialog parented to a window is
closed after the window it was parented to.

Reported-by: Ivan Molodetskikh <yalterz@gmail.com>
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
This commit is contained in:
Sergey Bugaev
2024-09-30 18:51:14 +03:00
parent d7ab7e9628
commit 2103ab99a5

View File

@@ -6381,6 +6381,9 @@ gtk_window_export_handle (GtkWindow *window,
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
ExportHandleData *data;
if (G_UNLIKELY (!priv->surface))
return FALSE;
data = g_new (ExportHandleData, 1);
data->window = window;
data->callback = callback;
@@ -6397,7 +6400,8 @@ gtk_window_unexport_handle (GtkWindow *window,
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
gdk_toplevel_unexport_handle (GDK_TOPLEVEL (priv->surface), unprefix_handle (handle));
if (G_LIKELY (priv->surface))
gdk_toplevel_unexport_handle (GDK_TOPLEVEL (priv->surface), unprefix_handle (handle));
}
static GtkPointerFocus *