[GameStudio] Crash whenever the user changes a struct value in the property grid
Release Type: Latest built in debug
Describe the bug Let's say you have a
public class MyComp : StartupScript
{
public List<Test2> MyField = new List<Test2>();
[DataContract] public struct Test2{ public bool b; }
}
Adding a new item and setting its b field to true in the property grid crashes the gamestudio.
Why ? An AssetMemberNode instance runs its Update function, note the NotifyContentChanging and NotifyContentChanged below:
https://github.com/stride3d/stride/blob/ba36a7e03d6ced082996a6628b80fe7edaf0cacb/sources/presentation/Stride.Core.Quantum/MemberNode.cs#L102-L124
NotifyContentChanging calls OnPropertyChanged on an AssetNodeViewModel instance with name b and value false further down the stack:
https://github.com/stride3d/stride/blob/ba36a7e03d6ced082996a6628b80fe7edaf0cacb/sources/presentation/Stride.Core.Presentation/ViewModels/ViewModelBase.cs#L240-L260
Notice the hashset insertion wrapped inside a DEBUG scope.
After this, NotifyContentChanged from the first snippet runs, creating a new AssetNodeViewModel with name b and value true, then immediately calls https://github.com/stride3d/stride/blob/ba36a7e03d6ced082996a6628b80fe7edaf0cacb/sources/presentation/Stride.Core.Presentation/ViewModels/ViewModelBase.cs#L266-L289 on that new instance failing the hashset test since it's an all new instance.
Debugger screenshot for more context in order of execution:
This is the call to -Changing
Here, the creation of the new
AssetNodeViewModel
And the call to -Changed on that new
AssetNodeViewModel