forked from qt-creator/qt-creator
QtcProcess: Add a warning when starting a process in non-QThread
When a QProcess is being started in a thread that doesn't have event dispatcher installed, e.g. in a thread started with std::async(), the process signals are emitted only from inside QProcess::waitFor...() functions, but not emitted spontaneously. This may cause issues when adding the running process into the ProcessReaper, as the implementation of the latter relies on signal emission and doesn't use blocking API of QProcess. Currently there is one case like this: ProcessCreator::createProcess() of clangsupport library. Change-Id: I823a139b356f62fee9e0e5d6fc8326301c36b449 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -367,6 +367,9 @@ private:
|
||||
|
||||
void doDefaultStart(const QString &program, const QStringList &arguments) final
|
||||
{
|
||||
QTC_ASSERT(QThread::currentThread()->eventDispatcher(),
|
||||
qWarning("QtcProcess::start(): Starting a process in a non QThread thread "
|
||||
"may cause infinite hang when destroying the running process."));
|
||||
ProcessStartHandler *handler = m_process->processStartHandler();
|
||||
handler->setProcessMode(m_setup.m_processMode);
|
||||
handler->setWriteData(m_setup.m_writeData);
|
||||
|
Reference in New Issue
Block a user