Skip to content

Commit

Permalink
Delay fs update when populating path bimap
Browse files Browse the repository at this point in the history
  • Loading branch information
paulloz committed Feb 1, 2024
1 parent 9adb7c7 commit 999180d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,6 @@ static void LookupScriptForClass(Type type)

_pathTypeBiMap.Add(scriptPathAttr.Path, type);

// This method may be called before initialization.
if (NativeFuncs.godotsharp_dotnet_module_is_initialized().ToBool() && Engine.IsEditorHint())
{
using godot_string scriptPath = Marshaling.ConvertStringToNative(scriptPathAttr.Path);
NativeFuncs.godotsharp_internal_editor_file_system_update_file(scriptPath);
}

if (AlcReloadCfg.IsAlcReloadingEnabled)
{
AddTypeForAlcReloading(type);
Expand Down Expand Up @@ -366,6 +359,16 @@ static void LookupScriptForClass(Type type)
}
}
}

// This method may be called before initialization.
if (NativeFuncs.godotsharp_dotnet_module_is_initialized().ToBool() && Engine.IsEditorHint())
{
foreach (var scriptPath in _pathTypeBiMap.Paths)
{
using godot_string nativeScriptPath = Marshaling.ConvertStringToNative(scriptPath);
NativeFuncs.godotsharp_internal_editor_file_system_update_file(nativeScriptPath);
}
}
}

[UnmanagedCallersOnly]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ private class PathScriptTypeBiMap
private System.Collections.Generic.Dictionary<string, Type> _pathTypeMap = new();
private System.Collections.Generic.Dictionary<Type, string> _typePathMap = new();

public System.Collections.Generic.IEnumerable<string> Paths => _pathTypeMap.Keys;

public void Add(string scriptPath, Type scriptType)
{
_pathTypeMap.Add(scriptPath, scriptType);
Expand Down

0 comments on commit 999180d

Please sign in to comment.