Skip to content

Commit

Permalink
Fix udev thread quitting
Browse files Browse the repository at this point in the history
  • Loading branch information
Eeems committed Jul 1, 2023
1 parent 1ab39f5 commit 6f07a2a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions shared/liboxide/udev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace Oxide {
connect(parent, &QObject::destroyed, this, &QObject::deleteLater);
connect(&_thread, &QThread::started, this, &UDev::run);
connect(&_thread, &QThread::finished, [this]{
qDebug() << "UDev::Stopped";
running = false;
});
moveToThread(&_thread);
Expand All @@ -35,7 +36,6 @@ namespace Oxide {
qDebug() << "UDev::Starting...";
running = true;
_thread.start();
qDebug() << "UDev::Started";
}

void UDev::stop(){
Expand All @@ -44,18 +44,14 @@ namespace Oxide {
running = false;
wait();
}
qDebug() << "UDev::Stopped";
}

bool UDev::isRunning(){ return running || _thread.isRunning(); }

void UDev::wait(){
qDebug() << "UDev::Waiting...";
while(isRunning()){
qApp->processEvents();
thread()->yieldCurrentThread();
if(isRunning()){
_thread.wait();
}
qDebug() << "UDev::Waited";
}

void UDev::addMonitor(QString subsystem, QString deviceType){
Expand Down Expand Up @@ -185,6 +181,7 @@ namespace Oxide {
}
O_DEBUG("UDev::Monitor stopping");
udev_monitor_unref(mon);
_thread.quit();
}
QDebug operator<<(QDebug debug, const UDev::Device& device){
QDebugStateSaver saver(debug);
Expand Down

0 comments on commit 6f07a2a

Please sign in to comment.