stride icon indicating copy to clipboard operation
stride copied to clipboard

[GameStudio] Crash whenever the user changes a struct value in the property grid

Open Eideren opened this issue 1 year ago • 1 comments

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.

Eideren avatar Sep 04 '24 17:09 Eideren

Debugger screenshot for more context in order of execution: This is the call to -Changing image Here, the creation of the new AssetNodeViewModel image And the call to -Changed on that new AssetNodeViewModel image

Eideren avatar Sep 04 '24 17:09 Eideren