Skip to content

Commit

Permalink
Defer EditorInspector::update_tree to the process stage to improve …
Browse files Browse the repository at this point in the history
…performance

`EditorInspector::update_tree` is expensive, so defer the call to the process phase
to prevent multiple calls in a single frame (when switching scene tabs).
  • Loading branch information
Rindbee committed Dec 17, 2022
1 parent 2e657e5 commit f352c30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2597,7 +2597,7 @@ bool EditorInspector::_is_property_disabled_by_feature_profile(const StringName
return false;
}

void EditorInspector::update_tree() {
void EditorInspector::_update_tree() {
//to update properly if all is refreshed
StringName current_selected = property_selected;
int current_focusable = -1;
Expand Down Expand Up @@ -3316,6 +3316,10 @@ void EditorInspector::update_tree() {
}
}

void EditorInspector::update_tree() {
update_tree_pending = true;
}

void EditorInspector::update_property(const String &p_prop) {
if (!editor_property_map.has(p_prop)) {
return;
Expand Down Expand Up @@ -3910,10 +3914,9 @@ void EditorInspector::_notification(int p_what) {
changing++;

if (update_tree_pending) {
update_tree();
update_tree_pending = false;
pending.clear();

_update_tree();
} else {
while (pending.size()) {
StringName prop = *pending.begin();
Expand Down
2 changes: 2 additions & 0 deletions editor/editor_inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,8 @@ class EditorInspector : public ScrollContainer {
void _show_add_meta_dialog();
void _check_meta_name(const String &p_name);

void _update_tree();

protected:
static void _bind_methods();
void _notification(int p_what);
Expand Down

0 comments on commit f352c30

Please sign in to comment.