2019-11-20 00:11:30 -05:00
|
|
|
/**
|
2026-01-18 12:53:55 -06:00
|
|
|
* @file ProcessThread.cpp
|
|
|
|
|
* @brief ProcessThread::setProcess
|
|
|
|
|
* @param proc - process to move to this thread and take ownership
|
2019-11-20 00:11:30 -05:00
|
|
|
* (C) 2019 Jordan Sherer <kn4crd@gmail.com> - All Rights Reserved
|
2026-01-18 12:53:55 -06:00
|
|
|
*/
|
2019-11-20 00:11:30 -05:00
|
|
|
#include "ProcessThread.h"
|
|
|
|
|
|
2026-01-01 15:12:24 -06:00
|
|
|
ProcessThread::ProcessThread(QObject *parent) : QThread(parent) {}
|
2019-11-20 00:11:30 -05:00
|
|
|
|
2026-01-01 15:12:24 -06:00
|
|
|
ProcessThread::~ProcessThread() { setProcess(nullptr); }
|
2019-11-20 00:11:30 -05:00
|
|
|
|
2026-01-01 15:12:24 -06:00
|
|
|
void ProcessThread::setProcess(QProcess *proc, int msecs) {
|
|
|
|
|
if (!m_proc.isNull()) {
|
2019-11-20 00:11:30 -05:00
|
|
|
bool b = m_proc->waitForFinished(msecs);
|
2026-01-01 15:12:24 -06:00
|
|
|
if (!b)
|
|
|
|
|
m_proc->close();
|
2019-11-20 00:11:30 -05:00
|
|
|
m_proc.reset();
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-01 15:12:24 -06:00
|
|
|
if (proc) {
|
2019-11-20 00:11:30 -05:00
|
|
|
proc->moveToThread(this);
|
|
|
|
|
m_proc.reset(proc);
|
|
|
|
|
}
|
|
|
|
|
}
|