From 2ee0606a560f63abfbfba4133ae6d741ac717102 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Thu, 22 Aug 2024 17:59:00 -0400 Subject: [PATCH] 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. --- launcher/include/processwatcher.h | 3 +-- launcher/src/processwatcher.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/launcher/include/processwatcher.h b/launcher/include/processwatcher.h index 5f71790..ef5ded6 100644 --- a/launcher/include/processwatcher.h +++ b/launcher/include/processwatcher.h @@ -3,7 +3,6 @@ #pragma once -#include #include /// 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(); diff --git a/launcher/src/processwatcher.cpp b/launcher/src/processwatcher.cpp index 69339f8..245943f 100644 --- a/launcher/src/processwatcher.cpp +++ b/launcher/src/processwatcher.cpp @@ -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(); } \ No newline at end of file