InspectorProperty.PopDraw() Causes Exception

Issue #498 open
Tim Williams
created an issue

It appears InspectorProperty.PopDraw() does not check if the drawCountStack has any elements. This leads to an exception being thrown if it tries to pop from an empty stack.

I was able to cause an exception like this by creating a button and inside the button function calling

EditorUtility.DisplayCancelableProgressBar()

Calling that produced the following exception:

InvalidOperationException: Stack empty.
System.Collections.Generic.Stack`1[T].ThrowForEmptyStack () (at <343bdfbb3c2d4d21b745a87548c1a7cd>:0)
System.Collections.Generic.Stack`1[T].Pop () (at <343bdfbb3c2d4d21b745a87548c1a7cd>:0)
Sirenix.OdinInspector.Editor.InspectorProperty.PopDraw () (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Examples/Attributes/TitleExamples.cs:49)
Sirenix.OdinInspector.Editor.InspectorProperty.Draw (UnityEngine.GUIContent defaultLabel) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Examples/Attributes/TableMatrixExamples.cs:43)
Sirenix.OdinInspector.Editor.InspectorUtilities.DrawPropertiesInTree (Sirenix.OdinInspector.Editor.PropertyTree tree) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/PersistentContext/PersistentContextCache.cs:209)
Rethrow as OdinPropertyException: This error occurred while being drawn by Odin.
Odin Property Path: TryRunWizard
Odin Drawer Chain: DisableInPlayModeAttributeDrawer, EnableIfAttributeDrawer, DefaultMethodDrawer.
UnityEngine.Debug:LogException(Exception)
Sirenix.OdinInspector.Editor.InspectorUtilities:DrawPropertiesInTree(PropertyTree) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/PersistentContext/PersistentContextCache.cs:209)
Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Group Drawers/ResponsiveButtonGroupAttributeDrawer.cs:32)
Sirenix.OdinInspector.Editor.OdinEditorWindow:DrawEditor(Int32)
Sirenix.OdinInspector.Editor.OdinEditorWindow:DrawEditors() (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyListValueEntryChanger.cs:133)
Sirenix.OdinInspector.Editor.OdinEditorWindow:OnGUI() (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyListValueEntryChanger.cs:118)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Comments (5)

  1. Tim Williams reporter

    It tends to happen any time a function in an OdinEditorWindow with the [Button()] attribute makes an extended running call, whether that's importing assets or other longer running functions. The errors are thrown once the button function finishes and exits.

  2. Tim Williams reporter

    Putting the following code in an OdinEditorWindow class will cause the error:

    [Button("SomeTestButton")]
            private void CauseError()
            {
                if (EditorUtility.DisplayCancelableProgressBar("Odin Test", "This will cause an error", 0))
                    return;
    
                EditorUtility.ClearProgressBar();
            }
    
  3. Log in to comment