|
@@ -3371,6 +3371,9 @@ void EditorNode::_remove_edited_scene(bool p_change_tab) {
|
|
|
}
|
|
|
|
|
|
void EditorNode::_remove_scene(int index, bool p_change_tab) {
|
|
|
+ // Clear icon cache in case some scripts are no longer needed.
|
|
|
+ script_icon_cache.clear();
|
|
|
+
|
|
|
if (editor_data.get_edited_scene() == index) {
|
|
|
//Scene to remove is current scene
|
|
|
_remove_edited_scene(p_change_tab);
|
|
@@ -4018,7 +4021,7 @@ void EditorNode::_pick_main_scene_custom_action(const String &p_custom_action_na
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-Ref<Texture> EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) const {
|
|
|
+Ref<Texture> EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) {
|
|
|
ERR_FAIL_COND_V(!p_object || !gui_base, nullptr);
|
|
|
|
|
|
Ref<Script> script = p_object->get_script();
|
|
@@ -4026,13 +4029,14 @@ Ref<Texture> EditorNode::get_object_icon(const Object *p_object, const String &p
|
|
|
script = p_object;
|
|
|
}
|
|
|
|
|
|
- if (script.is_valid()) {
|
|
|
+ if (script.is_valid() && !script_icon_cache.has(script)) {
|
|
|
Ref<Script> base_script = script;
|
|
|
while (base_script.is_valid()) {
|
|
|
StringName name = EditorNode::get_editor_data().script_class_get_name(base_script->get_path());
|
|
|
String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(name);
|
|
|
Ref<ImageTexture> icon = _load_custom_class_icon(icon_path);
|
|
|
if (icon.is_valid()) {
|
|
|
+ script_icon_cache[script] = icon;
|
|
|
return icon;
|
|
|
}
|
|
|
|
|
@@ -4042,12 +4046,18 @@ Ref<Texture> EditorNode::get_object_icon(const Object *p_object, const String &p
|
|
|
const Vector<EditorData::CustomType> &types = EditorNode::get_editor_data().get_custom_types()[base];
|
|
|
for (int i = 0; i < types.size(); ++i) {
|
|
|
if (types[i].script == base_script && types[i].icon.is_valid()) {
|
|
|
+ script_icon_cache[script] = types[i].icon;
|
|
|
return types[i].icon;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
base_script = base_script->get_base_script();
|
|
|
}
|
|
|
+
|
|
|
+ // If no icon found, cache it as null.
|
|
|
+ script_icon_cache[script] = Ref<Texture>();
|
|
|
+ } else if (script.is_valid() && script_icon_cache.has(script) && script_icon_cache[script].is_valid()) {
|
|
|
+ return script_icon_cache[script];
|
|
|
}
|
|
|
|
|
|
// should probably be deprecated in 4.x
|