Merge pull request #91595 from ajreckof/fix-infinite-call-loop-on-theme-change

Fix infinite call loop on theme change.
This commit is contained in:
Rémi Verschelde 2024-05-13 15:47:30 +02:00
commit 4fe9764ba9
No known key found for this signature in database
GPG Key ID: C3336907360768E1
4 changed files with 24 additions and 21 deletions

View File

@ -50,6 +50,7 @@
#include "scene/property_utils.h" #include "scene/property_utils.h"
#include "scene/resources/packed_scene.h" #include "scene/resources/packed_scene.h"
#include "scene/resources/style_box_flat.h" #include "scene/resources/style_box_flat.h"
#include "scene/scene_string_names.h"
bool EditorInspector::_property_path_matches(const String &p_property_path, const String &p_filter, EditorPropertyNameProcessor::Style p_style) { bool EditorInspector::_property_path_matches(const String &p_property_path, const String &p_filter, EditorPropertyNameProcessor::Style p_style) {
if (p_property_path.containsn(p_filter)) { if (p_property_path.containsn(p_filter)) {
@ -390,6 +391,17 @@ void EditorProperty::_notification(int p_what) {
delete_rect = Rect2(); delete_rect = Rect2();
} }
} break; } break;
case NOTIFICATION_ENTER_TREE: {
if (has_borders) {
get_parent()->connect(SceneStringName(theme_changed), callable_mp(this, &EditorProperty::_update_property_bg));
_update_property_bg();
}
} break;
case NOTIFICATION_EXIT_TREE: {
if (has_borders) {
get_parent()->disconnect(SceneStringName(theme_changed), callable_mp(this, &EditorProperty::_update_property_bg));
}
}
} }
} }
@ -810,6 +822,9 @@ void EditorProperty::set_label_reference(Control *p_control) {
void EditorProperty::set_bottom_editor(Control *p_control) { void EditorProperty::set_bottom_editor(Control *p_control) {
bottom_editor = p_control; bottom_editor = p_control;
if (has_borders) {
_update_property_bg();
}
} }
Variant EditorProperty::_get_cache_value(const StringName &p_prop, bool &r_valid) const { Variant EditorProperty::_get_cache_value(const StringName &p_prop, bool &r_valid) const {
@ -4087,6 +4102,9 @@ void EditorInspector::_notification(int p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
bool needs_update = false; bool needs_update = false;
if (EditorThemeManager::is_generated_theme_outdated() && !sub_inspector) {
add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree")));
}
if (use_settings_name_style && EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/localize_settings")) { if (use_settings_name_style && EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/localize_settings")) {
EditorPropertyNameProcessor::Style style = EditorPropertyNameProcessor::get_settings_style(); EditorPropertyNameProcessor::Style style = EditorPropertyNameProcessor::get_settings_style();

View File

@ -136,6 +136,8 @@ private:
void _update_pin_flags(); void _update_pin_flags();
protected: protected:
bool has_borders = false;
void _notification(int p_what); void _notification(int p_what);
static void _bind_methods(); static void _bind_methods();
virtual void _set_read_only(bool p_read_only); virtual void _set_read_only(bool p_read_only);

View File

@ -3364,8 +3364,6 @@ void EditorPropertyResource::update_property() {
EditorNode::get_singleton()->hide_unused_editors(); EditorNode::get_singleton()->hide_unused_editors();
opened_editor = false; opened_editor = false;
} }
_update_property_bg();
} }
} }
} }
@ -3422,12 +3420,6 @@ bool EditorPropertyResource::is_colored(ColorationMode p_mode) {
void EditorPropertyResource::_notification(int p_what) { void EditorPropertyResource::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
if (EditorThemeManager::is_generated_theme_outdated()) {
_update_property_bg();
}
} break;
case NOTIFICATION_EXIT_TREE: { case NOTIFICATION_EXIT_TREE: {
const EditorInspector *ei = get_parent_inspector(); const EditorInspector *ei = get_parent_inspector();
if (ei && !ei->is_main_editor_inspector()) { if (ei && !ei->is_main_editor_inspector()) {
@ -3439,6 +3431,7 @@ void EditorPropertyResource::_notification(int p_what) {
EditorPropertyResource::EditorPropertyResource() { EditorPropertyResource::EditorPropertyResource() {
use_sub_inspector = bool(EDITOR_GET("interface/inspector/open_resources_in_current_inspector")); use_sub_inspector = bool(EDITOR_GET("interface/inspector/open_resources_in_current_inspector"));
has_borders = true;
} }
////////////// DEFAULT PLUGIN ////////////////////// ////////////// DEFAULT PLUGIN //////////////////////

View File

@ -391,8 +391,6 @@ void EditorPropertyArray::update_property() {
paginator->connect("page_changed", callable_mp(this, &EditorPropertyArray::_page_changed)); paginator->connect("page_changed", callable_mp(this, &EditorPropertyArray::_page_changed));
vbox->add_child(paginator); vbox->add_child(paginator);
_update_property_bg();
for (int i = 0; i < page_length; i++) { for (int i = 0; i < page_length; i++) {
_create_new_property_slot(); _create_new_property_slot();
} }
@ -454,7 +452,6 @@ void EditorPropertyArray::update_property() {
memdelete(container); memdelete(container);
button_add_item = nullptr; button_add_item = nullptr;
container = nullptr; container = nullptr;
_update_property_bg();
slots.clear(); slots.clear();
} }
} }
@ -628,10 +625,6 @@ Node *EditorPropertyArray::get_base_node() {
void EditorPropertyArray::_notification(int p_what) { void EditorPropertyArray::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_THEME_CHANGED:
if (EditorThemeManager::is_generated_theme_outdated()) {
_update_property_bg();
}
[[fallthrough]];
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE: {
change_type->clear(); change_type->clear();
for (int i = 0; i < Variant::VARIANT_MAX; i++) { for (int i = 0; i < Variant::VARIANT_MAX; i++) {
@ -851,6 +844,7 @@ EditorPropertyArray::EditorPropertyArray() {
subtype = Variant::NIL; subtype = Variant::NIL;
subtype_hint = PROPERTY_HINT_NONE; subtype_hint = PROPERTY_HINT_NONE;
subtype_hint_string = ""; subtype_hint_string = "";
has_borders = true;
} }
///////////////////// DICTIONARY /////////////////////////// ///////////////////// DICTIONARY ///////////////////////////
@ -1000,7 +994,6 @@ void EditorPropertyDictionary::update_property() {
paginator = memnew(EditorPaginator); paginator = memnew(EditorPaginator);
paginator->connect("page_changed", callable_mp(this, &EditorPropertyDictionary::_page_changed)); paginator->connect("page_changed", callable_mp(this, &EditorPropertyDictionary::_page_changed));
vbox->add_child(paginator); vbox->add_child(paginator);
_update_property_bg();
for (int i = 0; i < page_length; i++) { for (int i = 0; i < page_length; i++) {
_create_new_property_slot(slots.size()); _create_new_property_slot(slots.size());
@ -1075,7 +1068,6 @@ void EditorPropertyDictionary::update_property() {
memdelete(container); memdelete(container);
button_add_item = nullptr; button_add_item = nullptr;
container = nullptr; container = nullptr;
_update_property_bg();
add_panel = nullptr; add_panel = nullptr;
slots.clear(); slots.clear();
} }
@ -1089,10 +1081,6 @@ void EditorPropertyDictionary::_object_id_selected(const StringName &p_property,
void EditorPropertyDictionary::_notification(int p_what) { void EditorPropertyDictionary::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_THEME_CHANGED:
if (EditorThemeManager::is_generated_theme_outdated()) {
_update_property_bg();
}
[[fallthrough]];
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE: {
change_type->clear(); change_type->clear();
for (int i = 0; i < Variant::VARIANT_MAX; i++) { for (int i = 0; i < Variant::VARIANT_MAX; i++) {
@ -1109,6 +1097,7 @@ void EditorPropertyDictionary::_notification(int p_what) {
if (button_add_item) { if (button_add_item) {
button_add_item->set_icon(get_editor_theme_icon(SNAME("Add"))); button_add_item->set_icon(get_editor_theme_icon(SNAME("Add")));
add_panel->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("DictionaryAddItem")));
} }
} break; } break;
} }
@ -1166,6 +1155,7 @@ EditorPropertyDictionary::EditorPropertyDictionary() {
add_child(change_type); add_child(change_type);
change_type->connect("id_pressed", callable_mp(this, &EditorPropertyDictionary::_change_type_menu)); change_type->connect("id_pressed", callable_mp(this, &EditorPropertyDictionary::_change_type_menu));
changing_type_index = -1; changing_type_index = -1;
has_borders = true;
} }
///////////////////// LOCALIZABLE STRING /////////////////////////// ///////////////////// LOCALIZABLE STRING ///////////////////////////