Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Prevent repeated resource counting when changing scene

kobewi9dda154bd36d
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 69aa0f2c9f8..3425997b64e 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -702,6 +702,19 @@ void EditorNode::_propagate_translation_notification() {
scene_root->propagate_notification(NOTIFICATION_TRANSLATION_CHANGED);
}
+void EditorNode::_queue_resource_counter_changed() {
+ if (resource_counter_queued) {
+ return;
+ }
+ callable_mp(this, &EditorNode::_emit_resource_counter_changed).call_deferred();
+ resource_counter_queued = true;
+}
+
+void EditorNode::_emit_resource_counter_changed() {
+ resource_counter_queued = false;
+ emit_signal(SNAME("resource_counter_changed"));
+}
+
void EditorNode::_update_system_menu_icons(bool p_dark_mode) {
file_menu->set_item_icon(file_menu->get_item_index(SCENE_NEW_SCENE), get_editor_theme_native_menu_icon(SNAME("CreateNewSceneFrom"), menu_type == MENU_TYPE_GLOBAL, p_dark_mode));
file_menu->set_item_icon(file_menu->get_item_index(SCENE_OPEN_SCENE), get_editor_theme_native_menu_icon(SNAME("PackedScene"), menu_type == MENU_TYPE_GLOBAL, p_dark_mode));
@@ -2076,8 +2089,7 @@ void EditorNode::update_resource_count(Node *p_node, bool p_remove) {
resource_count[R].push_back(p_node);
}
}
-
- emit_signal(SNAME("resource_counter_changed"));
+ _queue_resource_counter_changed();
}
int EditorNode::get_resource_count(Ref<Resource> p_res) {
@@ -2111,7 +2123,7 @@ void EditorNode::update_node_reference(const Variant &p_value, Node *p_node, boo
}
}
}
- emit_signal(SNAME("resource_counter_changed"));
+ _queue_resource_counter_changed();
}
void EditorNode::clear_node_reference(Ref<Resource> p_res) {
diff --git a/editor/editor_node.h b/editor/editor_node.h
index f943b00d4b9..e1e4214bbec 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -464,6 +464,7 @@ private:
bool requested_first_scan = false;
bool waiting_for_first_scan = true;
bool load_editor_layout_done = false;
+ bool resource_counter_queued = false;
HashSet<Ref<Translation>> tracked_translations;
bool pending_translation_notification = false;
@@ -647,6 +648,8 @@ private:
void _translation_resources_changed();
void _queue_translation_notification();
void _propagate_translation_notification();
+ void _queue_resource_counter_changed();
+ void _emit_resource_counter_changed();
void _renderer_selected(int p_index);
void _update_renderer_color();