Skip to content

Commit

Permalink
Detect wrong thread
Browse files Browse the repository at this point in the history
  • Loading branch information
Eeems committed Jul 1, 2023
1 parent d9c05db commit 9f6d240
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions shared/liboxide/udev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down

0 comments on commit 9f6d240

Please sign in to comment.