forked from qt-creator/qt-creator
QtcProcess: Introduce a way to track long-running blocking processes
...in the main thread. Set QTC_PROCESS_THRESHOLD (in ms) to receive warnings for them. Change-Id: Ia9e9c14b5ca339bfa2be82930518f988f56620c2 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
a8bc009595
commit
c72638ed74
@@ -1730,6 +1730,10 @@ void QtcProcess::runBlocking(EventLoopMode eventLoopMode)
|
||||
// Attach a dynamic property with info about blocking type
|
||||
d->storeEventLoopDebugInfo(int(eventLoopMode));
|
||||
|
||||
QDateTime startTime;
|
||||
static const int blockingThresholdMs = qtcEnvironmentVariableIntValue("QTC_PROCESS_THRESHOLD");
|
||||
if (blockingThresholdMs > 0 && isMainThread())
|
||||
startTime = QDateTime::currentDateTime();
|
||||
QtcProcess::start();
|
||||
|
||||
// Remove the dynamic property so that it's not reused in subseqent start()
|
||||
@@ -1773,6 +1777,13 @@ void QtcProcess::runBlocking(EventLoopMode eventLoopMode)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (blockingThresholdMs > 0) {
|
||||
const int timeDiff = startTime.msecsTo(QDateTime::currentDateTime());
|
||||
if (timeDiff > blockingThresholdMs && isMainThread()) {
|
||||
qWarning() << "Blocking process " << d->m_setup.m_commandLine << "took" << timeDiff
|
||||
<< "ms, longer than threshold" << blockingThresholdMs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QtcProcess::setStdOutCallback(const TextChannelCallback &callback)
|
||||
|
||||
Reference in New Issue
Block a user