Skip to content

Commit 1a439ae

Browse files
authored
Fix Qt apps crash (#739)
Avoid a crash by g_return_if_fail() and a return with the same condition Original Mutter's MR https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1559
1 parent ffd0d37 commit 1a439ae

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/wayland/meta-wayland-xdg-shell.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ typedef struct _MetaWaylandXdgSurfacePrivate
8989
struct wl_resource *resource;
9090
MetaWaylandXdgShellClient *shell_client;
9191
MetaRectangle geometry;
92+
MetaRectangle unconstrained_geometry;
9293

9394
guint configure_sent : 1;
9495
guint first_buffer_attached : 1;
@@ -807,7 +808,7 @@ meta_wayland_xdg_toplevel_post_apply_state (MetaWaylandSurfaceRole *surface_rol
807808
META_WAYLAND_SURFACE_ROLE_CLASS (meta_wayland_xdg_toplevel_parent_class);
808809
surface_role_class->post_apply_state (surface_role, pending);
809810

810-
if (!pending->newly_attached)
811+
if (!surface->buffer_ref.buffer)
811812
return;
812813

813814
window_geometry = meta_wayland_xdg_surface_get_window_geometry (xdg_surface);
@@ -1533,6 +1534,7 @@ meta_wayland_xdg_surface_real_reset (MetaWaylandXdgSurface *xdg_surface)
15331534
priv->first_buffer_attached = FALSE;
15341535
priv->configure_sent = FALSE;
15351536
priv->geometry = (MetaRectangle) { 0 };
1537+
priv->unconstrained_geometry = (MetaRectangle) { 0 };
15361538
priv->has_set_geometry = FALSE;
15371539
}
15381540

@@ -1575,12 +1577,19 @@ meta_wayland_xdg_surface_post_apply_state (MetaWaylandSurfaceRole *surface_role
15751577

15761578
if (pending->has_new_geometry)
15771579
{
1580+
priv->unconstrained_geometry = pending->new_geometry;
15781581
meta_wayland_shell_surface_determine_geometry (shell_surface,
15791582
&pending->new_geometry,
15801583
&priv->geometry);
15811584
priv->has_set_geometry = TRUE;
15821585
}
1583-
else if (!priv->has_set_geometry)
1586+
else if (priv->has_set_geometry)
1587+
{
1588+
meta_wayland_shell_surface_determine_geometry (shell_surface,
1589+
&priv->unconstrained_geometry,
1590+
&priv->geometry);
1591+
}
1592+
else
15841593
{
15851594
MetaRectangle new_geometry = { 0 };
15861595

src/wayland/meta-window-wayland.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct _MetaWindowWayland
5353
GList *pending_configurations;
5454
gboolean has_pending_state_change;
5555

56+
gboolean has_last_sent_configuration;
5657
int last_sent_x;
5758
int last_sent_y;
5859
int last_sent_width;
@@ -188,6 +189,10 @@ surface_state_changed (MetaWindow *window)
188189
if (window->unmanaging)
189190
return;
190191

192+
g_return_if_fail (wl_window->has_last_sent_configuration);
193+
if (!wl_window->has_last_sent_configuration)
194+
return;
195+
191196
configuration =
192197
meta_wayland_window_configuration_new (wl_window->last_sent_x,
193198
wl_window->last_sent_y,
@@ -401,6 +406,7 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
401406
}
402407
}
403408

409+
wl_window->has_last_sent_configuration = TRUE;
404410
wl_window->last_sent_x = configured_x;
405411
wl_window->last_sent_y = configured_y;
406412
wl_window->last_sent_width = configured_width;
@@ -1000,7 +1006,14 @@ meta_window_wayland_finish_move_resize (MetaWindow *window,
10001006
else
10011007
{
10021008
if (acked_configuration)
1003-
calculate_offset (acked_configuration, &new_geom, &rect);
1009+
{
1010+
calculate_offset (acked_configuration, &new_geom, &rect);
1011+
}
1012+
else
1013+
{
1014+
rect.x = window->rect.x;
1015+
rect.y = window->rect.y;
1016+
}
10041017
}
10051018

10061019
if (rect.x != window->rect.x || rect.y != window->rect.y)

0 commit comments

Comments
 (0)