summaryrefslogtreecommitdiff
path: root/editor/editor_node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r--editor/editor_node.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index f4caa29a47..194021669f 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -31,7 +31,6 @@
#include "editor_node.h"
#include "core/config/project_settings.h"
-#include "core/extension/native_extension_manager.h"
#include "core/input/input.h"
#include "core/io/config_file.h"
#include "core/io/file_access.h"
@@ -1883,7 +1882,7 @@ void EditorNode::_dialog_action(String p_file) {
ProjectSettings::get_singleton()->save();
// TODO: Would be nice to show the project manager opened with the highlighted field.
- if (pick_main_scene->has_meta("from_native") && (bool)pick_main_scene->get_meta("from_native")) {
+ if ((bool)pick_main_scene->get_meta("from_native", false)) {
run_native->resume_run_native();
} else {
_run(false, ""); // Automatically run the project.
@@ -3406,6 +3405,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);
@@ -3942,12 +3944,9 @@ void EditorNode::register_editor_types() {
GDREGISTER_CLASS(EditorScenePostImport);
GDREGISTER_CLASS(EditorCommandPalette);
GDREGISTER_CLASS(EditorDebuggerPlugin);
-
- NativeExtensionManager::get_singleton()->initialize_extensions(NativeExtension::INITIALIZATION_LEVEL_EDITOR);
}
void EditorNode::unregister_editor_types() {
- NativeExtensionManager::get_singleton()->deinitialize_extensions(NativeExtension::INITIALIZATION_LEVEL_EDITOR);
_init_callbacks.clear();
if (EditorPaths::get_singleton()) {
EditorPaths::free();
@@ -4059,7 +4058,7 @@ void EditorNode::_pick_main_scene_custom_action(const String &p_custom_action_na
}
}
-Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) const {
+Ref<Texture2D> 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();
@@ -4067,13 +4066,14 @@ Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String
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;
}
@@ -4083,12 +4083,18 @@ Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String
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];
}
// TODO: Should probably be deprecated in 4.x.
@@ -5890,6 +5896,7 @@ EditorNode::EditorNode() {
SceneState::set_disable_placeholders(true);
ResourceLoader::clear_translation_remaps(); // Using no remaps if in editor.
ResourceLoader::clear_path_remaps();
+ ResourceLoader::set_create_missing_resources_if_class_unavailable(true);
Input *id = Input::get_singleton();