From 6fa2e00425daf5a77f52419e0dbe479964f52aed Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Sat, 20 Jan 2024 21:03:13 +0100 Subject: [PATCH] Process: Get rid of internal event loop field It was only needed for runBlocking() in event loop mode. Handle it locally from the runBlocking() function. Change-Id: I6eb0830b223977bbf0fc73f0cdf4f3b4cab962b5 Reviewed-by: Orgad Shaneh --- src/libs/utils/process.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/libs/utils/process.cpp b/src/libs/utils/process.cpp index 90bc0c4045d..b79c01155a9 100644 --- a/src/libs/utils/process.cpp +++ b/src/libs/utils/process.cpp @@ -836,7 +836,6 @@ public: ProcessResultData m_resultData; QTextCodec *m_codec = QTextCodec::codecForLocale(); - QEventLoop *m_eventLoop = nullptr; ProcessResult m_result = ProcessResult::StartFailed; ChannelBuffer m_stdOut; ChannelBuffer m_stdErr; @@ -1865,8 +1864,6 @@ void Process::runBlocking(EventLoopMode eventLoopMode) QGuiApplication::setOverrideCursor(Qt::WaitCursor); #endif QEventLoop eventLoop(this); - QTC_ASSERT(!d->m_eventLoop, return); - d->m_eventLoop = &eventLoop; // Queue the call to start() so that it's executed after the nested event loop is started, // otherwise it fails on Windows with QProcessImpl. See QTCREATORBUG-30066. @@ -1888,8 +1885,9 @@ void Process::runBlocking(EventLoopMode eventLoopMode) QTimer::singleShot(d->m_timeoutInSeconds * 1000, &eventLoop, timeoutHandler); } + connect(this, &Process::done, &eventLoop, [&eventLoop] { eventLoop.quit(); }); + eventLoop.exec(QEventLoop::ExcludeUserInputEvents); - d->m_eventLoop = nullptr; #ifdef QT_GUI_LIB if (isGuiEnabled()) QGuiApplication::restoreOverrideCursor(); @@ -2066,8 +2064,6 @@ void ProcessPrivate::handleDone(const ProcessResultData &data) break; } } - if (m_eventLoop) - m_eventLoop->quit(); m_stdOut.handleRest(); m_stdErr.handleRest();