@@ -1684,24 +1684,30 @@ void SceneTreeDialog::_show_all_nodes_changed(bool p_button_pressed) {
16841684}
16851685
16861686void SceneTreeDialog::set_valid_types (const Vector<StringName> &p_valid) {
1687- if (p_valid.is_empty ()) {
1688- return ;
1687+ if (allowed_types_hbox) {
1688+ allowed_types_hbox->queue_free ();
1689+ allowed_types_hbox = nullptr ;
1690+ valid_type_icons.clear ();
16891691 }
16901692
16911693 tree->set_valid_types (p_valid);
16921694
1693- HBoxContainer *hbox = memnew (HBoxContainer);
1694- content->add_child (hbox);
1695- content->move_child (hbox, 0 );
1695+ if (p_valid.is_empty ()) {
1696+ return ;
1697+ }
1698+
1699+ allowed_types_hbox = memnew (HBoxContainer);
1700+ content->add_child (allowed_types_hbox);
1701+ content->move_child (allowed_types_hbox, 0 );
16961702
16971703 {
16981704 Label *label = memnew (Label);
1699- hbox ->add_child (label);
1705+ allowed_types_hbox ->add_child (label);
17001706 label->set_text (TTR (" Allowed:" ));
17011707 }
17021708
17031709 HFlowContainer *hflow = memnew (HFlowContainer);
1704- hbox ->add_child (hflow);
1710+ allowed_types_hbox ->add_child (hflow);
17051711 hflow->set_h_size_flags (Control::SIZE_EXPAND_FILL);
17061712
17071713 for (const StringName &type : p_valid) {
@@ -1735,6 +1741,9 @@ void SceneTreeDialog::set_valid_types(const Vector<StringName> &p_valid) {
17351741 }
17361742
17371743 show_all_nodes->show ();
1744+ if (is_inside_tree ()) {
1745+ _update_valid_type_icons ();
1746+ }
17381747}
17391748
17401749void SceneTreeDialog::_notification (int p_what) {
@@ -1753,11 +1762,7 @@ void SceneTreeDialog::_notification(int p_what) {
17531762 } break ;
17541763
17551764 case NOTIFICATION_THEME_CHANGED: {
1756- filter->set_right_icon (get_editor_theme_icon (SNAME (" Search" )));
1757- for (TextureRect *trect : valid_type_icons) {
1758- trect->set_custom_minimum_size (Vector2 (get_theme_constant (SNAME (" class_icon_size" ), EditorStringName (Editor)), 0 ));
1759- trect->set_texture (trect->get_meta (" icon" ));
1760- }
1765+ _update_valid_type_icons ();
17611766 } break ;
17621767
17631768 case NOTIFICATION_EXIT_TREE: {
@@ -1766,6 +1771,14 @@ void SceneTreeDialog::_notification(int p_what) {
17661771 }
17671772}
17681773
1774+ void SceneTreeDialog::_update_valid_type_icons () {
1775+ filter->set_right_icon (get_editor_theme_icon (SNAME (" Search" )));
1776+ for (TextureRect *trect : valid_type_icons) {
1777+ trect->set_custom_minimum_size (Vector2 (get_theme_constant (SNAME (" class_icon_size" ), EditorStringName (Editor)), 0 ));
1778+ trect->set_texture (trect->get_meta (" icon" ));
1779+ }
1780+ }
1781+
17691782void SceneTreeDialog::_cancel () {
17701783 hide ();
17711784}
0 commit comments