Merge pull request #99798 from preslavnpetrov/master
[C#] Fix thread deadlock when using a worker thread to load a script with a generic base class
This commit is contained in:
@ -493,6 +493,8 @@ namespace Godot.Bridge
|
|||||||
{
|
{
|
||||||
_scriptTypeBiMap.ReadWriteLock.ExitUpgradeableReadLock();
|
_scriptTypeBiMap.ReadWriteLock.ExitUpgradeableReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NativeFuncs.godotsharp_internal_reload_registered_script(outScript->Reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static unsafe void GetOrLoadOrCreateScriptForType(Type scriptType, godot_ref* outScript)
|
internal static unsafe void GetOrLoadOrCreateScriptForType(Type scriptType, godot_ref* outScript)
|
||||||
@ -527,12 +529,14 @@ namespace Godot.Bridge
|
|||||||
|
|
||||||
CreateScriptBridgeForType(scriptType, outScript);
|
CreateScriptBridgeForType(scriptType, outScript);
|
||||||
scriptPath = null;
|
scriptPath = null;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
_scriptTypeBiMap.ReadWriteLock.ExitUpgradeableReadLock();
|
_scriptTypeBiMap.ReadWriteLock.ExitUpgradeableReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NativeFuncs.godotsharp_internal_reload_registered_script(outScript->Reference);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string GetVirtualConstructedGenericTypeScriptPath(Type scriptType, string scriptPath)
|
static string GetVirtualConstructedGenericTypeScriptPath(Type scriptType, string scriptPath)
|
||||||
@ -597,6 +601,9 @@ namespace Godot.Bridge
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WARNING: We need to make sure that after unlocking the bimap, we call godotsharp_internal_reload_registered_script
|
||||||
|
/// </summary>
|
||||||
private static unsafe void CreateScriptBridgeForType(Type scriptType, godot_ref* outScript)
|
private static unsafe void CreateScriptBridgeForType(Type scriptType, godot_ref* outScript)
|
||||||
{
|
{
|
||||||
Debug.Assert(!scriptType.IsGenericTypeDefinition, $"Script type must be a constructed generic type or not generic at all. Type: {scriptType}.");
|
Debug.Assert(!scriptType.IsGenericTypeDefinition, $"Script type must be a constructed generic type or not generic at all. Type: {scriptType}.");
|
||||||
@ -613,8 +620,6 @@ namespace Godot.Bridge
|
|||||||
{
|
{
|
||||||
_scriptTypeBiMap.ReadWriteLock.ExitWriteLock();
|
_scriptTypeBiMap.ReadWriteLock.ExitWriteLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeFuncs.godotsharp_internal_reload_registered_script(outScript->Reference);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[UnmanagedCallersOnly]
|
[UnmanagedCallersOnly]
|
||||||
|
|||||||
Reference in New Issue
Block a user