Open Appleguysnake opened 6 months ago
Bonus: If you delete the graph when it has corrupt graph data as in #50 the error is different:
ArgumentException: Object at index 0 is null
UnityEditor.SerializedObject..ctor (UnityEngine.Object obj) (at <80a8ce1980c648dca8e68f0d8aa3b930>:0)
NewGraph.GraphModelBase.CreateSerializedObject (UnityEngine.Object scope, System.String rootFieldName) (at Assets/NewGraph/Models/GraphModelBase.cs:147)
NewGraph.MonoGraphModel.CreateSerializedObject () (at Assets/NewGraph/Models/MonoGraphModel.cs:61)
NewGraph.MonoGraphModel.get_BaseObject () (at Assets/NewGraph/Models/MonoGraphModel.cs:44)
NewGraph.GraphSettings.SetLastOpenedGraphData (NewGraph.IGraphModelData graphData) (at Assets/NewGraph/Editor/Settings/GraphSettings.cs:36)
NewGraph.GraphController+<>c__DisplayClass43_0.<Load>b__0 () (at Assets/NewGraph/Editor/Controllers/GraphController.cs:452)
UnityEngine.UIElements.VisualElement+SimpleScheduledItem.PerformTimerUpdate (UnityEngine.UIElements.TimerState state) (at <332857d8803a4878904bcf8f9581ec33>:0)
UnityEngine.UIElements.TimerEventScheduler.UpdateScheduledEvents () (at <332857d8803a4878904bcf8f9581ec33>:0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.UpdateSchedulers () (at <332857d8803a4878904bcf8f9581ec33>:0)
UnityEngine.UIElements.UIEventRegistration.UpdateSchedulers () (at <332857d8803a4878904bcf8f9581ec33>:0)
UnityEditor.RetainedMode.UpdateSchedulers () (at <cc76bab7efe9480f901125fd04a708b6>:0)
Pretty obvious what went wrong when this happens, but errors are thrown every update so it seems like it should be handled in some way.
Repro
Result: this error is thrown until the window is closed
Expected result
I'm not sure what the preferred / simplest way to handle this would be. When deleting open scenes in Unity, the behavior is that the scene is marked dirty and you're asked if you want to save it whenever you close it or the editor. Just closing the graph window would make sense as well. Catching the error and throwing a message to tell the user to close the window also seems fine.