xdg-shell: Early out of apply if dismissed

We might end up trying to apply a pending state late if it was delayed
by DMA buffers not being ready. Trying to discard the pending state from
the transaction when dismissing is hard, because we might be applying a
chain of transactions that would disqualify subsequent transactions if a
former one dismisses the popup, so lets just drop what the apply would
otherwise do, if we're not going to use it anyway.

This fixes the following crash:

  0) meta_wayland_surface_get_window (surface=0x0)
  1) meta_wayland_xdg_popup_apply_state (surface_role=0xf5ee80, pending=0xf662a0)
  2) meta_wayland_surface_role_apply_state (surface_role=0xf5ee80, pending=0xf662a0)
  3) meta_wayland_surface_apply_state (surface=0xf5e640, state=0xf662a0)
  4) meta_wayland_transaction_apply (transaction=0xf56170, first_candidate=0x7fffffffcee8)
  5) meta_wayland_transaction_maybe_apply_one (transaction=0xf56170, first_candidate=0x7fffffffcee8)
  6) meta_wayland_transaction_maybe_apply (transaction=0xf56170)
  7) meta_wayland_transaction_dma_buf_dispatch (buffer=0xf448a0, user_data=0xf56200)
  8) meta_wayland_dma_buf_source_dispatch (base=0xf5f140, callback=0x0, user_data=0x0)
  9) g_main_dispatch (context=0x41baa0)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2940>
This commit is contained in:
Jonas Ådahl 2023-03-28 23:07:54 +02:00
parent 50a37a7fc0
commit 47b6e76578

View File

@ -1239,6 +1239,9 @@ meta_wayland_xdg_popup_apply_state (MetaWaylandSurfaceRole *surface_role,
if (xdg_popup->setup.parent_surface) if (xdg_popup->setup.parent_surface)
finish_popup_setup (xdg_popup); finish_popup_setup (xdg_popup);
if (!meta_wayland_surface_get_window (surface))
return;
if (pending->xdg_positioner) if (pending->xdg_positioner)
{ {
MetaWindow *window, *parent_window; MetaWindow *window, *parent_window;