qt: Fix double free when multi-monitor is enabled and evdev is used

This commit is contained in:
Cacodemon345
2022-07-13 23:55:37 +06:00
parent d4360235fd
commit a61f10fe55

View File

@@ -70,6 +70,7 @@ void evdev_thread_func()
for (unsigned int i = 0; i < evdev_mice.size(); i++) for (unsigned int i = 0; i < evdev_mice.size(); i++)
{ {
libevdev_free(evdev_mice[i].second); libevdev_free(evdev_mice[i].second);
evdev_mice[i].second = nullptr;
close(evdev_mice[i].first); close(evdev_mice[i].first);
} }
evdev_mice.clear(); evdev_mice.clear();
@@ -77,12 +78,16 @@ void evdev_thread_func()
void evdev_stop() void evdev_stop()
{ {
stopped = true; if (evdev_thread) {
evdev_thread->wait(); stopped = true;
evdev_thread->wait();
evdev_thread = nullptr;
}
} }
void evdev_init() void evdev_init()
{ {
if (evdev_thread) return;
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
{ {
std::string evdev_device_path = "/dev/input/event" + std::to_string(i); std::string evdev_device_path = "/dev/input/event" + std::to_string(i);