Page 1 of 1

NullReferenceException: SerializedObject of SerializedProperty has been Disposed.

Posted: 2025/05/24 22:44
by FunctionOverflu
Hello,

Logic Toolkit: 1.9.0
Unity: 6000.1.2f1

Once in a while this error keeps showing up in the Unity editor while I am testing the logic toolkit logic.
The only way to stop it is to restart Unity editor, closing the logic editor or opening a different scene doesn't fix it.

Any idea why and how it can be fixed?

Code: Select all

NullReferenceException: SerializedObject of SerializedProperty has been Disposed.
UnityEditor.SerializedProperty.Verify (UnityEditor.SerializedProperty+VerifyFlags verifyFlags) (at <316d3d2a3f8c4b19b769e5bc4918c7d7>:0)
UnityEditor.SerializedProperty.get_longValue () (at <316d3d2a3f8c4b19b769e5bc4918c7d7>:0)
LogicToolkit.Editors.ManagedReferenceDataPropertyBase`1[T].get_Id () (at ./Packages/com.caitsithware.logictoolkit/Editor/Serialization/ManagedReferenceDataProperty.cs:23)
LogicToolkit.Editors.NodeElement.SetActive (System.Boolean isActive) (at ./Packages/com.caitsithware.logictoolkit/Editor/Graph/UIElements/NodeElement.cs:852)
LogicToolkit.Editors.ComputeNodeBaseEditor.OnComputed () (at ./Packages/com.caitsithware.logictoolkit/Editor/Graph/Dataflow/NodeEditors/ComputeNodeEditor.cs:81)
LogicToolkit.Editors.DelayCallback`1+Callback[T].OnUpdate () (at ./Packages/com.caitsithware.logictoolkit/Editor/Graph/Callbacks/DelayCallback.cs:99)
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at <316d3d2a3f8c4b19b769e5bc4918c7d7>:0)

Re: NullReferenceException: SerializedObject of SerializedProperty has been Disposed.

Posted: 2025/05/24 23:51
by caitsithware
Thank you for your report.

Based on the log contents, it seems that this occurs when object destruction and ComputeNode processing occur at the same time.
We will confirm the reproducibility and fix it.

If this error starts to occur, the temporary solution is as follows.
  • Open any script
  • Insert a blank line or something and save
  • Wait for compilation and domain reload to complete
This should also unregister the invalid callback.

Re: NullReferenceException: SerializedObject of SerializedProperty has been Disposed.

Posted: 2025/05/25 00:06
by FunctionOverflu
Thank you!
Yeah I also couldn't find the way to consistently reproduce it, but I will try the method you mentioned if it happens again.

Re: NullReferenceException: SerializedObject of SerializedProperty has been Disposed.

Posted: 2025/05/25 00:31
by caitsithware
I tried to reproduce the problem but was unable to do so.
This may be a problem that is easily affected by the timing of ComputeNode execution.

For now, I will take the following measures.
  1. Open Packages/com.caitsithware.logictoolkit/Editor/Graph/Dataflow/NodeEditors/ComputeNodeEditor.cs in a code editor
  2. Insert the following code at the beginning of the ComputeNodeBaseEditor class

    Code: Select all

    private bool _IsAttached = false;
  3. Insert the following code at the beginning of the OnAttachToPanel method

    Code: Select all

    _IsAttached = true;
  4. Insert the following code at the beginning of the OnDetachFromPanel method

    Code: Select all

    _IsAttached = false;
  5. Insert the following code at the beginning of the OnPlayModeStateChanged method

    Code: Select all

    if (!_IsAttached) return;
  6. Insert the following code at the beginning of the OnComputed method

    Code: Select all

    if (!_IsAttached) return;