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 <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Alessandro Portale
2023-10-20 11:44:27 +02:00
parent e454dc0f1f
commit 76bcd85f21

View File

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