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 <eike.ziller@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2018-08-08 10:42:35 +02:00
parent 975f5886a6
commit 36d21d5760

View File

@@ -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();