io/process: mask the "QProcess destroyed for running process" warn

This commit is contained in:
outfoxxed 2025-07-02 20:16:47 -07:00
parent f681e2016f
commit 86591f122d
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
5 changed files with 88 additions and 3 deletions

View file

@ -27,6 +27,21 @@ Process::Process(QObject* parent): QObject(parent) {
);
}
Process::~Process() {
if (this->process != nullptr && this->process->processId() != 0) {
// Deleting after the process finishes hides the process destroyed warning in logs
QObject::connect(this->process, &QProcess::finished, [p = this->process] { delete p; });
this->process->setParent(nullptr);
this->process->kill();
}
}
void Process::onPostReload() {
this->postReload = true;
this->startProcessIfReady();
}
bool Process::isRunning() const { return this->process != nullptr; }
void Process::setRunning(bool running) {
@ -165,7 +180,9 @@ void Process::setStdinEnabled(bool enabled) {
}
void Process::startProcessIfReady() {
if (this->process != nullptr || !this->targetRunning || this->mCommand.isEmpty()) return;
if (this->process != nullptr || !this->postReload || !this->targetRunning
|| this->mCommand.isEmpty())
return;
this->targetRunning = false;
auto& cmd = this->mCommand.first();