QtcProcess: Fix crash when logging process stats

Change-Id: I204366a008dea91d1b2b946689c7598fe9ab009c
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2022-02-28 15:36:37 +01:00
parent 7b234e0fae
commit 92de389a61

View File

@@ -711,7 +711,11 @@ QtcProcess::QtcProcess(QObject *parent)
if (processLog().isDebugEnabled()) {
connect(this, &QtcProcess::finished, [this] {
if (const QVariant n = d->m_process.get()->property(QTC_PROCESS_NUMBER); n.isValid()) {
if (!d->m_process.get())
return;
const QVariant n = d->m_process.get()->property(QTC_PROCESS_NUMBER);
if (!n.isValid())
return;
using namespace std::chrono;
const quint64 msSinceEpoc =
duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
@@ -732,7 +736,6 @@ QtcProcess::QtcProcess(QObject *parent)
if (processStderrLog().isDebugEnabled() && !stdErr().isEmpty())
qCDebug(processStderrLog).nospace()
<< "Process " << number << " stderr: " << stdErr();
}
});
}
}