Inspector dock's "Show in FileSystem" can be invoked via its shortcut while showing as disabled, crashing with an ERR_FAIL_COND
Tested versions
Reproducible in: 4.8.dev (e16296832)
I have not tested other versions in this session, but this is very unlikely to be a recent regression: InspectorDock::_get_current_resource() (the function the crashing code path relies on) has only ever cast the currently inspected object to Resource, with no history of ever handling a plain Node, and the popup's disabled-state refresh timing described below has been the same since this dock's "resource extra" popup was introduced. I could not find any commit that changed this behavior.
System information
Godot v4.8.dev (e16296832) - macOS Tahoe (26.6.2) - Multi-window, 1 monitor (3024x1964 @ 120.00 Hz) - Metal (Forward+) - integrated Apple M4 Pro (Apple9) - Apple M4 Pro (12 threads) - 24.00 GiB memory - CoreAudio (44100 Hz, Stereo/mono)
Issue description
The Inspector dock has a "resource extra" MenuButton popup (New Resource / Load Resource / Save / Save As / Edit Resource from Clipboard / Copy Resource / Show in FileSystem / Open Documentation / Make Resource Built-In), with several of its items also bound to a user-assignable keyboard shortcut (none of them ship with a default keybinding).
When the object currently shown in the Inspector is a Node rather than a Resource (for example, a node that is itself the root of an externally instantiated scene), the "Show in FileSystem" item is correctly shown as disabled if you actually open this popup. However, pressing its assigned shortcut without first opening the popup for this selection still runs the action, and it crashes with:
ERROR: Condition "current_res.is_null()" is true.
at: _menu_option_confirm (editor/docks/inspector_dock.cpp:108)Root cause: MenuButton::shortcut_input() dispatches to PopupMenu::activate_item_by_event(), which does correctly check is_item_disabled() before running the bound action -- but only against whatever disabled-state was last written to that specific item. Most of this popup's items (Save, Save As, Copy Resource, Make Resource Built-In, Open Documentation) have their disabled-state recomputed on every Inspector selection change (InspectorDock::update()). "Show in FileSystem" (and "Edit Resource from Clipboard") are the exception: their disabled-state is only recomputed when the popup is actually opened (_prepare_resource_extra_popup(), connected to the button's about_to_popup signal). So a pure keyboard shortcut press, without ever opening the popup for the current selection, can activate "Show in FileSystem" while it's actually invalid for the current selection -- its item never had a chance to be marked disabled in the first place.
Expected behavior: pressing the shortcut while the current object has no corresponding non-built-in Resource to show should simply do nothing (matching what the menu item's own disabled appearance already implies), not crash with an ERR_FAIL_COND.
I have a small, local fix ready (a single predicate, _is_menu_option_enabled(), used both to compute every item's disabled-state -- now refreshed uniformly and consistently for the whole popup -- and as an early-return guard at the top of _menu_option_confirm(), so a menu option can never actually run while invalid regardless of what any PopupMenu item's disabled flag happens to say at the moment) and will follow up with a pull request shortly after opening this issue.
Before (selecting a Node in the Inspector, then pressing the Inspector's "Show in FileSystem" shortcut without opening the popup first -- crashes with the error above):
After (with the fix applied, the same key press is a silent no-op, matching the item's own disabled state -- no error, no crash):
Steps to reproduce
- In Editor Settings -> Shortcuts, search for "Show in FileSystem" and assign a key combination to the Property Editor entry specifically (it has no default keybinding).
- In any project, select any Node in a scene (any node at all -- it does not need to be an instantiated sub-scene; a plain
Node3Dreproduces this too) so the Inspector shows its properties. - Without opening the Inspector's "resource extra" popup (the small button with the dropdown next to the object path, at the top of the Inspector) even once for this selection, press the shortcut assigned in step 1.
Expected: nothing happens -- no change in the FileSystem dock, no console output.
Actual: this is printed to the console, and nothing else happens:
ERROR: Condition "current_res.is_null()" is true.
at: _menu_option_confirm (editor/docks/inspector_dock.cpp:108)Minimal reproduction project (MRP)
N/A -- any project works, as long as it contains at least one Node to select in a scene (see step 2 above). No special project setup is required to reproduce this.
Source: godotengine/godot