Skip to content

Migrated UID Viewer from bottom‑panel dock to editor tool#1190

Closed
TheAenema wants to merge 1 commit into
Redot-Engine:devfrom
Selciner-Games:dev
Closed

Migrated UID Viewer from bottom‑panel dock to editor tool#1190
TheAenema wants to merge 1 commit into
Redot-Engine:devfrom
Selciner-Games:dev

Conversation

@TheAenema
Copy link
Copy Markdown
Contributor

@TheAenema TheAenema commented Feb 3, 2026

Repulled in #1249

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 3, 2026

Walkthrough

Refactors the UID Viewer from a dock (UIDViewerDock/VBoxContainer) into a Window-based tool (UIDViewer), adds EditorNode integration (instantiation, GUI child), exposes a Tools menu entry/shortcut that calls UIDViewer::_open_tool(), and adds lifecycle handling (_on_tool_closed).

Changes

Cohort / File(s) Summary
EditorNode integration
editor/editor_node.h, editor/editor_node.cpp
Adds UIDViewer forward-declaration and UIDViewer *uid_viewer member; instantiates UIDViewer, adds it as a GUI child; introduces TOOLS_UID_VIEWER menu option and shortcut; wires menu handler to call uid_viewer->_open_tool().
UID Viewer refactor (API + implementation)
editor/file_system/uid_viewer.h, editor/file_system/uid_viewer.cpp
Renames UIDViewerDockUIDViewer, changes base from VBoxContainer to Window, moves UI into an internal VBoxContainer* container, updates signal/handler names, adds _open_tool() and _on_tool_closed(), adjusts layout/visibility and window parameters.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EditorNode
    participant GUI
    participant UIDViewer
    participant FileSystem

    User->>EditorNode: Select "Tools → UID Viewer" (menu/shortcut)
    EditorNode->>UIDViewer: uid_viewer->_open_tool()
    UIDViewer->>GUI: popup_centered() / show window
    activate UIDViewer
    UIDViewer->>FileSystem: request UID list / refresh
    FileSystem-->>UIDViewer: return UID data
    UIDViewer-->>GUI: populate tree, focus search
    User->>UIDViewer: search / activate / context actions
    UIDViewer->>FileSystem: optional lookup/action
    Note right of UIDViewer: On close -> _on_tool_closed()
    deactivate UIDViewer
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • Arctis-Fireblight
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately summarizes the main change: migrating UID Viewer from a bottom-panel dock to an editor tool, which is the core objective of all file modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
editor/file_system/uid_viewer.h (1)

2-2: ⚠️ Potential issue | 🟡 Minor

Copyright header filename mismatch.

The comment still references the old filename uid_viewer_dock.h, but this file has been renamed to uid_viewer.h. This is confirmed by the pipeline failure indicating copyright header changes are needed.

Proposed fix
-/*  uid_viewer_dock.h                                                     */
+/*  uid_viewer.h                                                          */
editor/file_system/uid_viewer.cpp (2)

1-3: ⚠️ Potential issue | 🟡 Minor

Update the file banner to match the new filename.

The banner still says uid_viewer_dock.cpp, which no longer matches the path and can trigger the copyright-header hook. Rename it to uid_viewer.cpp.

🧾 Proposed fix
-/*  uid_viewer_dock.cpp                                                   */
+/*  uid_viewer.cpp                                                        */

101-142: ⚠️ Potential issue | 🟠 Major

Reset last_selected_item and hide context menu when the tree is rebuilt to prevent use-after-free.

uid_tree->clear() frees all TreeItems in Godot 4, invalidating cached pointers. If the context menu is open when _refresh_uid_list() is called, last_selected_item remains pointing to freed memory. A subsequent call to _on_context_menu_id_pressed() will dereference this invalid pointer (the null check on line 182 won't catch freed memory—only nullptr). Reset the pointer and close the menu to prevent use-after-free.

🛠️ Proposed fix
 void UIDViewer::_refresh_uid_list() {
 	uid_tree->clear();
+	last_selected_item = nullptr;
+	if (context_menu) {
+		context_menu->hide();
+	}
 	TreeItem *root = uid_tree->create_item();
🧹 Nitpick comments (1)
editor/file_system/uid_viewer.h (1)

35-36: Consider removing potentially redundant include.

scene/gui/control.h may be unnecessary since Window inherits from Control, and the header would be transitively included. However, this is a minor optimization and can be kept if explicit includes are preferred for clarity.

Regarding the static analysis error for scene/main/window.h: this is the standard Godot engine path for the Window class and should resolve correctly in the actual build environment.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@editor/file_system/uid_viewer.cpp`:
- Around line 267-274: The current UIDViewer::_open_tool() only checks is_open
and skips reopening if the tool is hidden but still marked open; update
_open_tool() to also test the actual visibility (e.g., using
is_visible_in_tree() or is_visible()) and if is_open is true but the control is
not visible, call popup_centered() and grab_focus() to reshow it; also ensure
the "close_requested" connection (callable_mp(this,
&UIDViewer::_on_tool_closed)) is only created once (or guarded) so duplicate
connects aren't made.

Comment on lines +267 to +274
void UIDViewer::_open_tool() {
if (!is_open) {
connect("close_requested", callable_mp(this, &UIDViewer::_on_tool_closed));
popup_centered();
is_open = true;
} else {
grab_focus();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Guard against hidden-but-open state.

If the window is hidden via another path (layout restore, editor teardown), is_open stays true and _open_tool() won’t reshow it. Consider re-opening when not visible.

Suggested fix
 void UIDViewer::_open_tool() {
-	if (!is_open) {
-		connect("close_requested", callable_mp(this, &UIDViewer::_on_tool_closed));
-		popup_centered();
-		is_open = true;
-	} else {
-		grab_focus();
-	}
+	if (!is_open || !is_visible()) {
+		if (!is_open) {
+			connect("close_requested", callable_mp(this, &UIDViewer::_on_tool_closed));
+		}
+		popup_centered();
+		is_open = true;
+	} else {
+		grab_focus();
+	}
 }
🤖 Prompt for AI Agents
In `@editor/file_system/uid_viewer.cpp` around lines 267 - 274, The current
UIDViewer::_open_tool() only checks is_open and skips reopening if the tool is
hidden but still marked open; update _open_tool() to also test the actual
visibility (e.g., using is_visible_in_tree() or is_visible()) and if is_open is
true but the control is not visible, call popup_centered() and grab_focus() to
reshow it; also ensure the "close_requested" connection (callable_mp(this,
&UIDViewer::_on_tool_closed)) is only created once (or guarded) so duplicate
connects aren't made.

@Selciner-Games Selciner-Games closed this by deleting the head repository Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants