From 76bcd85f215f8256230132df816c6d9eb89ec77d Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 20 Oct 2023 11:44:27 +0200 Subject: [PATCH] WebAssembly: Avoid soft assert on toolchain auto detection Windows only: When toolchains get restored on startup, WebAssemblyToolChain would try to add MinGW to an environment. That env is used for querying the compiler version. In order to find MinGW, the MinGW toolchain is queried from ToolChainManager. But since the ToolChainManager is not yet loaded at this moment, we get a QTC_CHEK assert from ToolChainManager::toolChain. This change prevents querying the ToolChainManager before it is loaded. The compiler version can successfully be determined without MinGW in path. Whether we really need to query compiler versions that early is another question outside the scope of this change. Change-Id: I46edbb80edc58d7465e90e99f7f8381708f704a1 Reviewed-by: David Schulz Reviewed-by: --- src/plugins/webassembly/webassemblytoolchain.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugins/webassembly/webassemblytoolchain.cpp b/src/plugins/webassembly/webassemblytoolchain.cpp index 3174e0e9548..925b7f5dbfb 100644 --- a/src/plugins/webassembly/webassemblytoolchain.cpp +++ b/src/plugins/webassembly/webassemblytoolchain.cpp @@ -42,6 +42,12 @@ static const Abi &toolChainAbi() static void addRegisteredMinGWToEnvironment(Environment &env) { + if (!ToolChainManager::isLoaded()) { + // Avoid querying the ToolChainManager before it is loaded, which is the case during + // toolchain restoration. The compiler version can be determined without MinGW in path. + return; + } + const ToolChain *toolChain = ToolChainManager::toolChain([](const ToolChain *t){ return t->typeId() == ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID; }); @@ -54,7 +60,7 @@ void WebAssemblyToolChain::addToEnvironment(Environment &env) const const FilePath emSdk = settings().emSdk(); WebAssemblyEmSdk::addToEnvironment(emSdk, env); if (env.osType() == OsTypeWindows) - addRegisteredMinGWToEnvironment(env); + addRegisteredMinGWToEnvironment(env); // qmake based builds require [mingw32-]make.exe } WebAssemblyToolChain::WebAssemblyToolChain() :