Fix Resource Watcher crash

This commit is contained in:
Ottermandias 2023-04-01 14:22:17 +02:00
parent 113078af90
commit d4738934f8
2 changed files with 27 additions and 25 deletions

View file

@ -95,35 +95,37 @@ internal unsafe struct Record
var path = handle->FileName().Clone(); var path = handle->FileName().Clone();
return new Record return new Record
{ {
Time = DateTime.UtcNow, Time = DateTime.UtcNow,
Path = path, Path = path,
OriginalPath = ByteString.Empty, OriginalPath = ByteString.Empty,
Collection = null, Collection = null,
Handle = handle, Handle = handle,
ResourceType = handle->FileType.ToFlag(), ResourceType = handle->FileType.ToFlag(),
Category = handle->Category.ToFlag(), Category = handle->Category.ToFlag(),
RefCount = handle->RefCount, RefCount = handle->RefCount,
RecordType = RecordType.Destruction, RecordType = RecordType.Destruction,
Synchronously = OptionalBool.Null, Synchronously = OptionalBool.Null,
ReturnValue = OptionalBool.Null, ReturnValue = OptionalBool.Null,
CustomLoad = OptionalBool.Null, CustomLoad = OptionalBool.Null,
AssociatedGameObject = string.Empty,
}; };
} }
public static Record CreateFileLoad(ByteString path, ResourceHandle* handle, bool ret, bool custom) public static Record CreateFileLoad(ByteString path, ResourceHandle* handle, bool ret, bool custom)
=> new() => new()
{ {
Time = DateTime.UtcNow, Time = DateTime.UtcNow,
Path = path.IsOwned ? path : path.Clone(), Path = path.IsOwned ? path : path.Clone(),
OriginalPath = ByteString.Empty, OriginalPath = ByteString.Empty,
Collection = null, Collection = null,
Handle = handle, Handle = handle,
ResourceType = handle->FileType.ToFlag(), ResourceType = handle->FileType.ToFlag(),
Category = handle->Category.ToFlag(), Category = handle->Category.ToFlag(),
RefCount = handle->RefCount, RefCount = handle->RefCount,
RecordType = RecordType.FileLoad, RecordType = RecordType.FileLoad,
Synchronously = OptionalBool.Null, Synchronously = OptionalBool.Null,
ReturnValue = ret, ReturnValue = ret,
CustomLoad = custom, CustomLoad = custom,
AssociatedGameObject = string.Empty,
}; };
} }

View file

@ -20,7 +20,7 @@ using Penumbra.UI.Classes;
namespace Penumbra.UI; namespace Penumbra.UI;
public partial class ResourceWatcher : IDisposable, ITab public class ResourceWatcher : IDisposable, ITab
{ {
public const int DefaultMaxEntries = 1024; public const int DefaultMaxEntries = 1024;
public const RecordType AllRecords = RecordType.Request | RecordType.ResourceLoad | RecordType.FileLoad | RecordType.Destruction; public const RecordType AllRecords = RecordType.Request | RecordType.ResourceLoad | RecordType.FileLoad | RecordType.Destruction;