Fix crash when generating project files with toolchain setup that fails

#1537
This commit is contained in:
Wojtek Figat
2023-10-02 18:57:40 +02:00
parent dd66ee3521
commit 4149da5f9e
2 changed files with 16 additions and 8 deletions

View File

@@ -244,7 +244,19 @@ namespace Flax.Build
/// <returns>The toolchain.</returns>
public Toolchain TryGetToolchain(TargetArchitecture targetArchitecture)
{
return HasRequiredSDKsInstalled ? GetToolchain(targetArchitecture) : null;
Toolchain result = null;
if (HasRequiredSDKsInstalled)
{
try
{
result = GetToolchain(targetArchitecture);
}
catch (Exception ex)
{
Log.Exception(ex);
}
}
return result;
}
/// <summary>
@@ -260,16 +272,12 @@ namespace Flax.Build
if (_toolchains == null)
_toolchains = new Dictionary<TargetArchitecture, Toolchain>();
var key = targetArchitecture;
Toolchain toolchain;
if (_toolchains.TryGetValue(key, out toolchain))
{
if (_toolchains.TryGetValue(targetArchitecture, out toolchain))
return toolchain;
}
toolchain = CreateToolchain(targetArchitecture);
_toolchains.Add(key, toolchain);
_toolchains.Add(targetArchitecture, toolchain);
return toolchain;
}