Skip to content

Commit

Permalink
Do not extend the InputDeviceHub lifetime beyond teardown (#3611)
Browse files Browse the repository at this point in the history
Fixes: #3610
  • Loading branch information
AlanGriffiths authored Sep 25, 2024
2 parents 6d79e7e + 9fb02e4 commit c89d7fd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/miral/input_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class miral::InputConfiguration::Touchpad::Self : public TouchpadInputConfigurat
class miral::InputConfiguration::Self
{
public:
std::shared_ptr<mir::input::InputDeviceHub> input_device_hub{};
std::weak_ptr<mir::input::InputDeviceHub> input_device_hub{};
std::shared_ptr<InputDeviceConfig> input_device_config;

auto mouse() -> Mouse;
Expand All @@ -48,9 +48,9 @@ class miral::InputConfiguration::Self

void apply(Mouse const& m)
{
if (input_device_hub)
if (auto const idh = input_device_hub.lock())
{
input_device_hub->for_each_mutable_input_device([&m](auto& input_device)
idh->for_each_mutable_input_device([&m](auto& input_device)
{
m.self->apply_to(input_device);
});
Expand All @@ -61,9 +61,9 @@ class miral::InputConfiguration::Self

void apply(Touchpad const& t)
{
if (input_device_hub)
if (auto const idh = input_device_hub.lock())
{
input_device_hub->for_each_mutable_input_device([&t](auto& input_device)
idh->for_each_mutable_input_device([&t](auto& input_device)
{
t.self->apply_to(input_device);
});
Expand Down

0 comments on commit c89d7fd

Please sign in to comment.