Browse Source

Change ClassDB::get_inheriters_from_class.

Yufeng Ying 6 months ago
parent
commit
4029051bb1

+ 2 - 2
core/core_bind.cpp

@@ -1437,8 +1437,8 @@ PackedStringArray ClassDB::get_class_list() const {
 }
 }
 
 
 PackedStringArray ClassDB::get_inheriters_from_class(const StringName &p_class) const {
 PackedStringArray ClassDB::get_inheriters_from_class(const StringName &p_class) const {
-	List<StringName> classes;
-	::ClassDB::get_inheriters_from_class(p_class, &classes);
+	LocalVector<StringName> classes;
+	::ClassDB::get_inheriters_from_class(p_class, classes);
 
 
 	PackedStringArray ret;
 	PackedStringArray ret;
 	ret.resize(classes.size());
 	ret.resize(classes.size());

+ 2 - 2
core/object/class_db.cpp

@@ -281,12 +281,12 @@ void ClassDB::get_extension_class_list(const Ref<GDExtension> &p_extension, List
 }
 }
 #endif
 #endif
 
 
-void ClassDB::get_inheriters_from_class(const StringName &p_class, List<StringName> *p_classes) {
+void ClassDB::get_inheriters_from_class(const StringName &p_class, LocalVector<StringName> &p_classes) {
 	Locker::Lock lock(Locker::STATE_READ);
 	Locker::Lock lock(Locker::STATE_READ);
 
 
 	for (const KeyValue<StringName, ClassInfo> &E : classes) {
 	for (const KeyValue<StringName, ClassInfo> &E : classes) {
 		if (E.key != p_class && _is_parent_class(E.key, p_class)) {
 		if (E.key != p_class && _is_parent_class(E.key, p_class)) {
-			p_classes->push_back(E.key);
+			p_classes.push_back(E.key);
 		}
 		}
 	}
 	}
 }
 }

+ 1 - 1
core/object/class_db.h

@@ -315,7 +315,7 @@ public:
 	static void get_extension_class_list(const Ref<GDExtension> &p_extension, List<StringName> *p_classes);
 	static void get_extension_class_list(const Ref<GDExtension> &p_extension, List<StringName> *p_classes);
 	static ObjectGDExtension *get_placeholder_extension(const StringName &p_class);
 	static ObjectGDExtension *get_placeholder_extension(const StringName &p_class);
 #endif
 #endif
-	static void get_inheriters_from_class(const StringName &p_class, List<StringName> *p_classes);
+	static void get_inheriters_from_class(const StringName &p_class, LocalVector<StringName> &p_classes);
 	static void get_direct_inheriters_from_class(const StringName &p_class, List<StringName> *p_classes);
 	static void get_direct_inheriters_from_class(const StringName &p_class, List<StringName> *p_classes);
 	static StringName get_parent_class_nocheck(const StringName &p_class);
 	static StringName get_parent_class_nocheck(const StringName &p_class);
 	static bool get_inheritance_chain_nocheck(const StringName &p_class, Vector<StringName> &r_result);
 	static bool get_inheritance_chain_nocheck(const StringName &p_class, Vector<StringName> &r_result);

+ 2 - 2
editor/editor_audio_buses.cpp

@@ -974,8 +974,8 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
 	effect_options->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); // Don't translate class names.
 	effect_options->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); // Don't translate class names.
 	effect_options->connect("index_pressed", callable_mp(this, &EditorAudioBus::_effect_add));
 	effect_options->connect("index_pressed", callable_mp(this, &EditorAudioBus::_effect_add));
 	add_child(effect_options);
 	add_child(effect_options);
-	List<StringName> effect_list;
-	ClassDB::get_inheriters_from_class("AudioEffect", &effect_list);
+	LocalVector<StringName> effect_list;
+	ClassDB::get_inheriters_from_class("AudioEffect", effect_list);
 	effect_list.sort_custom<StringName::AlphCompare>();
 	effect_list.sort_custom<StringName::AlphCompare>();
 	for (const StringName &E : effect_list) {
 	for (const StringName &E : effect_list) {
 		if (!ClassDB::can_instantiate(E) || ClassDB::is_virtual(E)) {
 		if (!ClassDB::can_instantiate(E) || ClassDB::is_virtual(E)) {

+ 2 - 2
editor/editor_resource_picker.cpp

@@ -607,8 +607,8 @@ static void _add_allowed_type(const StringName &p_type, List<StringName> *p_vect
 			p_vector->push_back(p_type);
 			p_vector->push_back(p_type);
 		}
 		}
 
 
-		List<StringName> inheriters;
-		ClassDB::get_inheriters_from_class(p_type, &inheriters);
+		LocalVector<StringName> inheriters;
+		ClassDB::get_inheriters_from_class(p_type, inheriters);
 		for (const StringName &S : inheriters) {
 		for (const StringName &S : inheriters) {
 			_add_allowed_type(S, p_vector);
 			_add_allowed_type(S, p_vector);
 		}
 		}

+ 2 - 2
editor/export/project_export.cpp

@@ -1531,8 +1531,8 @@ ProjectExportDialog::ProjectExportDialog() {
 	resources_vb->add_child(server_strip_message);
 	resources_vb->add_child(server_strip_message);
 
 
 	{
 	{
-		List<StringName> resource_names;
-		ClassDB::get_inheriters_from_class("Resource", &resource_names);
+		LocalVector<StringName> resource_names;
+		ClassDB::get_inheriters_from_class("Resource", resource_names);
 
 
 		PackedStringArray strippable;
 		PackedStringArray strippable;
 		for (const StringName &resource_name : resource_names) {
 		for (const StringName &resource_name : resource_names) {

+ 3 - 3
editor/gui/scene_tree_editor.cpp

@@ -1839,7 +1839,7 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from
 }
 }
 
 
 bool SceneTreeEditor::_is_script_type(const StringName &p_type) const {
 bool SceneTreeEditor::_is_script_type(const StringName &p_type) const {
-	return (script_types->find(p_type));
+	return (script_types->has(p_type));
 }
 }
 
 
 bool SceneTreeEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
 bool SceneTreeEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
@@ -2144,8 +2144,8 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope
 	ask_before_revoke_checkbox->set_tooltip_text(TTR("This dialog can also be enabled/disabled in the Editor Settings: Docks > Scene Tree > Ask Before Revoking Unique Name."));
 	ask_before_revoke_checkbox->set_tooltip_text(TTR("This dialog can also be enabled/disabled in the Editor Settings: Docks > Scene Tree > Ask Before Revoking Unique Name."));
 	vb->add_child(ask_before_revoke_checkbox);
 	vb->add_child(ask_before_revoke_checkbox);
 
 
-	script_types = memnew(List<StringName>);
-	ClassDB::get_inheriters_from_class("Script", script_types);
+	script_types = memnew(LocalVector<StringName>);
+	ClassDB::get_inheriters_from_class("Script", *script_types);
 }
 }
 
 
 SceneTreeEditor::~SceneTreeEditor() {
 SceneTreeEditor::~SceneTreeEditor() {

+ 1 - 1
editor/gui/scene_tree_editor.h

@@ -212,7 +212,7 @@ class SceneTreeEditor : public Control {
 
 
 	Timer *update_timer = nullptr;
 	Timer *update_timer = nullptr;
 
 
-	List<StringName> *script_types;
+	LocalVector<StringName> *script_types;
 	bool _is_script_type(const StringName &p_type) const;
 	bool _is_script_type(const StringName &p_type) const;
 
 
 	Vector<StringName> valid_types;
 	Vector<StringName> valid_types;

+ 2 - 2
editor/plugins/animation_blend_space_1d_editor.cpp

@@ -76,8 +76,8 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
 			animations_menu->clear();
 			animations_menu->clear();
 			animations_to_add.clear();
 			animations_to_add.clear();
 
 
-			List<StringName> classes;
-			ClassDB::get_inheriters_from_class("AnimationRootNode", &classes);
+			LocalVector<StringName> classes;
+			ClassDB::get_inheriters_from_class("AnimationRootNode", classes);
 			classes.sort_custom<StringName::AlphCompare>();
 			classes.sort_custom<StringName::AlphCompare>();
 
 
 			menu->add_submenu_node_item(TTR("Add Animation"), animations_menu);
 			menu->add_submenu_node_item(TTR("Add Animation"), animations_menu);

+ 2 - 2
editor/plugins/animation_blend_space_2d_editor.cpp

@@ -119,10 +119,10 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
 			menu->clear(false);
 			menu->clear(false);
 			animations_menu->clear();
 			animations_menu->clear();
 			animations_to_add.clear();
 			animations_to_add.clear();
-			List<StringName> classes;
+			LocalVector<StringName> classes;
 			classes.sort_custom<StringName::AlphCompare>();
 			classes.sort_custom<StringName::AlphCompare>();
 
 
-			ClassDB::get_inheriters_from_class("AnimationRootNode", &classes);
+			ClassDB::get_inheriters_from_class("AnimationRootNode", classes);
 			menu->add_submenu_node_item(TTR("Add Animation"), animations_menu);
 			menu->add_submenu_node_item(TTR("Add Animation"), animations_menu);
 
 
 			List<StringName> names;
 			List<StringName> names;

+ 2 - 2
editor/plugins/animation_state_machine_editor.cpp

@@ -631,8 +631,8 @@ void AnimationNodeStateMachineEditor::_open_menu(const Vector2 &p_position) {
 		}
 		}
 	}
 	}
 
 
-	List<StringName> classes;
-	ClassDB::get_inheriters_from_class("AnimationRootNode", &classes);
+	LocalVector<StringName> classes;
+	ClassDB::get_inheriters_from_class("AnimationRootNode", classes);
 	classes.sort_custom<StringName::AlphCompare>();
 	classes.sort_custom<StringName::AlphCompare>();
 
 
 	for (const StringName &class_name : classes) {
 	for (const StringName &class_name : classes) {

+ 2 - 2
modules/gdscript/gdscript_editor.cpp

@@ -921,8 +921,8 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a
 		node.insert_text = node.display.quote(p_quote_style);
 		node.insert_text = node.display.quote(p_quote_style);
 		r_result.insert(node.display, node);
 		r_result.insert(node.display, node);
 
 
-		List<StringName> native_classes;
-		ClassDB::get_inheriters_from_class("Node", &native_classes);
+		LocalVector<StringName> native_classes;
+		ClassDB::get_inheriters_from_class("Node", native_classes);
 		for (const StringName &E : native_classes) {
 		for (const StringName &E : native_classes) {
 			if (!ClassDB::is_class_exposed(E)) {
 			if (!ClassDB::is_class_exposed(E)) {
 				continue;
 				continue;