- changed status to resolved
Interrupting a Button action with EditorUtility.DisplayDialog results in InvalidOperationException in 2019.4
Issue #685
resolved
We’re getting a strange error when interacting with a certain button in one of our inspectors.
InvalidOperationException: Stack empty.
at System.Collections.Generic.Stack`1[T].ThrowForEmptyStack () [0x00000] in <14e3453b740b4bd690e8d4e5a013a715>:0
at System.Collections.Generic.Stack`1[T].Pop () [0x00008] in <14e3453b740b4bd690e8d4e5a013a715>:0
at Sirenix.OdinInspector.Editor.InspectorProperty.PopDraw () [0x00000] in X:\Repositories\sirenix-development\Sirenix Solution\Sirenix.OdinInspector.Editor\Core\InspectorProperty.cs:706
at Sirenix.OdinInspector.Editor.InspectorProperty.Draw (UnityEngine.GUIContent defaultLabel) [0x003e2] in X:\Repositories\sirenix-development\Sirenix Solution\Sirenix.OdinInspector.Editor\Core\InspectorProperty.cs:670
at Sirenix.OdinInspector.Editor.Drawers.ButtonGroupAttributeDrawer.DrawPropertyLayout (UnityEngine.GUIContent label) [0x00106] in X:\Repositories\sirenix-development\Sirenix Solution\Sirenix.OdinInspector.Editor\Drawers\Group Drawers\ButtonGroupAttributeDrawer.cs:69
at Sirenix.OdinInspector.Editor.OdinDrawer.DrawProperty (UnityEngine.GUIContent label) [0x00013] in X:\Repositories\sirenix-development\Sirenix Solution\Sirenix.OdinInspector.Editor\Drawers\OdinDrawer.cs:176
at Sirenix.OdinInspector.Editor.InspectorProperty.Draw (UnityEngine.GUIContent defaultLabel) [0x00204] in X:\Repositories\sirenix-development\Sirenix Solution\Sirenix.OdinInspector.Editor\Core\InspectorProperty.cs:602
Rethrow as OdinPropertyException: This error occurred while being drawn by Odin.
Current IMGUI event: Used
Odin Property Path: #_DefaultGroup
Odin Drawer Chain:
> ButtonGroupAttributeDrawer.
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
Sirenix.OdinInspector.Editor.InspectorProperty:Draw(GUIContent) (at X:\Repositories\sirenix-development\Sirenix Solution\Sirenix.OdinInspector.Editor\Core\InspectorProperty.cs:653)
Sirenix.OdinInspector.Editor.InspectorUtilities:DrawPropertiesInTree(PropertyTree) (at X:\Repositories\sirenix-development\Sirenix Solution\Sirenix.OdinInspector.Editor\Misc\InspectorUtilities.cs:418)
Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean) (at X:\Repositories\sirenix-development\Sirenix Solution\Sirenix.OdinInspector.Editor\Core\PropertyTree.cs:308)
Sirenix.OdinInspector.Editor.OdinEditor:DrawTree() (at X:\Repositories\sirenix-development\Sirenix Solution\Sirenix.OdinInspector.Editor\Drawers\OdinEditor.cs:93)
Sirenix.OdinInspector.Editor.OdinEditor:DrawOdinInspector() (at X:\Repositories\sirenix-development\Sirenix Solution\Sirenix.OdinInspector.Editor\Drawers\OdinEditor.cs:215)
Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI() (at X:\Repositories\sirenix-development\Sirenix Solution\Sirenix.OdinInspector.Editor\Drawers\OdinEditor.cs:85)
UnityEditor.UIElements.<>c__DisplayClass58_0:<CreateIMGUIInspectorFromEditor>b__0()
UnityEngine.UIElements.IMGUIContainer:DoOnGUI(Event, Matrix4x4, Rect, Boolean, Rect, Action, Boolean)
UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent(Event, Matrix4x4, Rect, Action, Boolean)
UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent(Event, Action, Boolean)
UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent(Event, Boolean)
UnityEngine.UIElements.IMGUIContainer:SendEventToIMGUI(EventBase, Boolean)
UnityEngine.UIElements.IMGUIContainer:HandleEvent(EventBase)
UnityEngine.UIElements.CallbackEventHandler:HandleEventAtTargetPhase(EventBase)
UnityEngine.UIElements.MouseCaptureDispatchingStrategy:DispatchEvent(EventBase, IPanel)
UnityEngine.UIElements.EventDispatcher:ApplyDispatchingStrategies(EventBase, IPanel, Boolean)
UnityEngine.UIElements.EventDispatcher:ProcessEvent(EventBase, IPanel)
UnityEngine.UIElements.EventDispatcher:ProcessEventQueue()
UnityEngine.UIElements.EventDispatcher:OpenGate()
UnityEngine.UIElements.EventDispatcherGate:Dispose()
UnityEngine.UIElements.EventDispatcher:ProcessEvent(EventBase, IPanel)
UnityEngine.UIElements.EventDispatcher:Dispatch(EventBase, IPanel, DispatchMode)
UnityEngine.UIElements.BaseVisualElementPanel:SendEvent(EventBase, DispatchMode)
UnityEngine.UIElements.UIElementsUtility:DoDispatch(BaseVisualElementPanel)
UnityEngine.UIElements.UIElementsUtility:ProcessEvent(Int32, IntPtr)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
After cutting attributes and code the button invoked in a few ways, we are fairly certain the issue is caused by UnityEditor.EditorUtility.DisplayDialog. It used to work flawlessly with Odin buttons, but after we moved from 2019.2 to 2019.4 such an interruption results in the error above. Maybe 2019.3 or 2019.4 changed how inspectors are drawn when a dialog is displayed, e.g. inserting an unexpected redraw too early. Here is an example of the code inside the button:
if (UnityEditor.EditorUtility.DisplayDialog
(
"Existing files",
$"There are {dirs.Length} directories and {files.Length} files in {dataPath} - continuing will delete them. Proceed?",
"Continue",
"Cancel"
))
{
DeleteData (dirs, files, true);
}
Unity version: 2019.4.1f1
Odin version: 2.1.13
Editor Only mode: No
OS: Windows 10 Pro 1903 x64
Comments (1)
-
- Log in to comment
Thanks for the report! I've looked into this issue and fixed it; the fix will be released with the next 3.0 beta patch (beta 3.0.0.3).