From 36d21d576013a25492a7454efba1c9e33724b242 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Wed, 8 Aug 2018 10:42:35 +0200 Subject: [PATCH] ProjectExplorer: reduce amount of concurrent running vcvars.bat scripts The concurrent execution of multiple batch scripts seems to be suspicious behavior for some of the anti virus solutions out there. Task-number: QTCREATORBUG-20868 Task-number: QTCREATORBUG-20637 Task-number: QTCREATORBUG-20829 Task-number: QTCREATORBUG-20886 Change-Id: I2a05ccf937218bca09227bf34f56da38123ffbe7 Reviewed-by: Eike Ziller Reviewed-by: Christian Stenger --- src/plugins/projectexplorer/msvctoolchain.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/plugins/projectexplorer/msvctoolchain.cpp b/src/plugins/projectexplorer/msvctoolchain.cpp index 8a277fe5f1f..8ed356a324d 100644 --- a/src/plugins/projectexplorer/msvctoolchain.cpp +++ b/src/plugins/projectexplorer/msvctoolchain.cpp @@ -26,6 +26,7 @@ #include "msvctoolchain.h" #include "msvcparser.h" +#include "projectexplorer.h" #include "projectexplorerconstants.h" #include "taskhub.h" #include "toolchainmanager.h" @@ -65,6 +66,16 @@ namespace Internal { // Helpers: // -------------------------------------------------------------------------- +static QThreadPool *envModThreadPool() +{ + static QThreadPool *pool = nullptr; + if (!pool) { + pool = new QThreadPool(ProjectExplorerPlugin::instance()); + pool->setMaxThreadCount(1); + } + return pool; +} + struct MsvcPlatform { MsvcToolChain::Platform platform; const char *name; @@ -647,7 +658,8 @@ MsvcToolChain::MsvcToolChain(Core::Id typeId, const QString &name, const Abi &ab : AbstractMsvcToolChain(typeId, l, d, abi, varsBat) , m_varsBatArg(varsBatArg) { - initEnvModWatcher(Utils::runAsync(&MsvcToolChain::environmentModifications, + initEnvModWatcher(Utils::runAsync(envModThreadPool(), + &MsvcToolChain::environmentModifications, varsBat, varsBatArg)); Q_ASSERT(!name.isEmpty()); @@ -739,7 +751,8 @@ bool MsvcToolChain::fromMap(const QVariantMap &data) m_environmentModifications = Utils::EnvironmentItem::itemsFromVariantList( data.value(QLatin1String(environModsKeyC)).toList()); - initEnvModWatcher(Utils::runAsync(&MsvcToolChain::environmentModifications, + initEnvModWatcher(Utils::runAsync(envModThreadPool(), + &MsvcToolChain::environmentModifications, m_vcvarsBat, m_varsBatArg)); return !m_vcvarsBat.isEmpty() && m_abi.isValid();