1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-22 20:47:45 +00:00

Small improvements to the ProcessWatcher API

Changes the PID parameter to qint64 to be consistent with KProcessList
and QProcess. Also adds a QObject parent parameter.
This commit is contained in:
Joshua Goins 2024-08-22 17:59:00 -04:00
parent 1b1dca1bfb
commit 2ee0606a56
2 changed files with 5 additions and 5 deletions

View file

@ -3,7 +3,6 @@
#pragma once
#include <QObject>
#include <QTimer>
/// Listens and waits for a process to finish.
@ -11,7 +10,7 @@ class ProcessWatcher : public QObject
{
Q_OBJECT
public:
explicit ProcessWatcher(const int PID);
explicit ProcessWatcher(qint64 PID, QObject *parent = nullptr);
Q_SIGNALS:
void finished();

View file

@ -7,9 +7,10 @@
#include "moc_processwatcher.cpp"
ProcessWatcher::ProcessWatcher(const int PID)
ProcessWatcher::ProcessWatcher(const qint64 PID, QObject *parent)
: QObject(parent)
{
m_timer = new QTimer();
m_timer = new QTimer(this);
connect(m_timer, &QTimer::timeout, this, [this, PID] {
const auto info = KProcessList::processInfo(PID);
// If we can't find the PID, bail!
@ -19,6 +20,6 @@ ProcessWatcher::ProcessWatcher(const int PID)
Q_EMIT finished();
}
});
m_timer->setInterval(std::chrono::seconds(30));
m_timer->setInterval(std::chrono::seconds(5));
m_timer->start();
}