diff --git a/shared/liboxide/udev.cpp b/shared/liboxide/udev.cpp index d4d09d6be..704448222 100644 --- a/shared/liboxide/udev.cpp +++ b/shared/liboxide/udev.cpp @@ -135,6 +135,18 @@ namespace Oxide { } void UDev::run(){ + if(QThread::currentThread() != &_thread){ + O_DEBUG("UDev::Monitor on wrong thread, attempting to run on correct thread"); + QTimer* timer = new QTimer(); + timer->moveToThread(&_thread); + timer->setSingleShot(true); + QObject::connect(timer, &QTimer::timeout, [=](){ + // main thread + run(); + timer->deleteLater(); + }); + QMetaObject::invokeMethod(timer, "start", Qt::BlockingQueuedConnection, Q_ARG(int, 0)); + } O_DEBUG("UDev::Monitor starting"); udev_monitor* mon = udev_monitor_new_from_netlink(udevLib, "udev"); if(!mon){