Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting graph while graph window is open throws errors #49

Open
loosegrid opened this issue Apr 4, 2024 · 1 comment
Open

Deleting graph while graph window is open throws errors #49

loosegrid opened this issue Apr 4, 2024 · 1 comment

Comments

@loosegrid
Copy link

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

  • Create a graph (I used MonoGraphModel) and open it
  • Add a node
  • Delete the graph component

Result: this error is thrown until the window is closed

SerializedObject target has been destroyed.
UnityEngine.StackTraceUtility:ExtractStackTrace ()
NewGraph.NodeModel:SetPosition (single,single) (at Assets/NewGraph/Models/NodeModel.cs:174)
NewGraph.NodeController:SetPosition (single,single) (at Assets/NewGraph/Editor/Controllers/NodeController.cs:67)
NewGraph.NodeView:SetPosition (UnityEngine.Vector2) (at Assets/NewGraph/Editor/Views/NodeView.cs:313)
GraphViewBase.GraphElement:ApplyDeltaToPosition (UnityEngine.Vector2) (at ./Library/PackageCache/com.gentlymad.graphviewbase@9e7e3c3574/Editor/Elements/Graph/GraphElement.cs:128)
GraphViewBase.GraphElementContainer:HandleDrag (GraphViewBase.DragEvent,GraphViewBase.BaseNode) (at ./Library/PackageCache/com.gentlymad.graphviewbase@9e7e3c3574/Editor/Elements/GraphElementContainer.cs:208)
GraphViewBase.GraphElementContainer:OnDrag (GraphViewBase.DragEvent) (at ./Library/PackageCache/com.gentlymad.graphviewbase@9e7e3c3574/Editor/Elements/GraphElementContainer.cs:202)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

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.

@loosegrid
Copy link
Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant