Skip to content

Commit

Permalink
Merge #2094
Browse files Browse the repository at this point in the history
2094: [input] Handle exceptions while handling udev events r=Saviq a=AlanGriffiths

By design, the event dispatcher does not expect exceptions to propagate. Fix a dispatchee that allows events to propagate.

Maybe fixes canonical/mir-kiosk#60

Co-authored-by: Alan Griffiths <[email protected]>
  • Loading branch information
bors[bot] and AlanGriffiths committed Jun 30, 2021
1 parent 1b8f979 commit c2faa29
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/platforms/evdev/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,16 @@ void mie::Platform::start()
std::make_shared<DispatchableUDevMonitor>(
*udev_context,
[this](auto type, auto const& device)
{
using namespace std::string_literals;
auto event_type= "unknown"s;
try
{
switch(type)
switch (type)
{
case mu::Monitor::ADDED:
{
event_type = "ADDED"s;
if (device.devnode())
{
/*
Expand Down Expand Up @@ -341,6 +346,7 @@ void mie::Platform::start()
}
case mu::Monitor::REMOVED:
{
event_type = "REMOVED"s;
for (auto const& input_device : this->devices)
{
auto device_udev = libinput_device_get_udev_device(input_device->device());
Expand All @@ -359,7 +365,13 @@ void mie::Platform::start()
default:
break;
}
});
}
catch (std::exception const& e)
{
auto const message = "Failed to handle UDev " + event_type + " event for " + device.syspath();
log(logging::Severity::warning, MIR_LOG_COMPONENT, std::make_exception_ptr(e), message);
}
});

platform_dispatchable->add_watch(udev_dispatchable);
platform_dispatchable->add_watch(libinput_dispatchable);
Expand Down

0 comments on commit c2faa29

Please sign in to comment.