Skip to content

Commit

Permalink
tablet_pad: fix crash on unmap
Browse files Browse the repository at this point in the history
If a view is unmapped, its unmap might be delayed by a transaction. In
that case, the wlr_surface may be destroyed while the surface appears
mapped => crash in tablet pad which is based on wlr_surface
  • Loading branch information
ammen99 committed Aug 30, 2023
1 parent a86e1e3 commit 25422c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/seat/tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ wf::tablet_pad_t::tablet_pad_t(wlr_input_device *pad) :
on_button.connect(&wlr_tablet_pad_from_input_device(pad)->events.button);
on_strip.connect(&wlr_tablet_pad_from_input_device(pad)->events.strip);
on_ring.connect(&wlr_tablet_pad_from_input_device(pad)->events.ring);

on_focus_destroy.set_callback([&] (auto) { update_focus(nullptr); });
}

void wf::tablet_pad_t::update_focus()
Expand Down Expand Up @@ -487,6 +489,12 @@ void wf::tablet_pad_t::update_focus(wlr_surface *focus_surface)
wlr_tablet_v2_tablet_pad_notify_enter(pad_v2, attached_to->tablet_v2, focus_surface);
}

on_focus_destroy.disconnect();
if (focus_surface)
{
on_focus_destroy.connect(&focus_surface->events.destroy);
}

old_focus = focus_surface;
}

Expand Down
1 change: 1 addition & 0 deletions src/core/seat/tablet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ struct tablet_pad_t : public input_device_impl_t
nonstd::observer_ptr<tablet_t> attached_to;

wf::wl_listener_wrapper on_attach, on_button, on_strip, on_ring;
wf::wl_listener_wrapper on_focus_destroy;

wf::signal::connection_t<wf::input_device_added_signal> on_device_added;
wf::signal::connection_t<wf::input_device_removed_signal> on_device_removed;
Expand Down

0 comments on commit 25422c9

Please sign in to comment.