Skip to content

Commit

Permalink
Merge pull request godotengine#91595 from ajreckof/fix-infinite-call-…
Browse files Browse the repository at this point in the history
…loop-on-theme-change

Fix infinite call loop on theme change.
  • Loading branch information
akien-mga committed May 13, 2024
2 parents 45ee0fd + 114ab9d commit 4fe9764
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
18 changes: 18 additions & 0 deletions editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "scene/property_utils.h"
#include "scene/resources/packed_scene.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) {
if (p_property_path.containsn(p_filter)) {
Expand Down Expand Up @@ -390,6 +391,17 @@ void EditorProperty::_notification(int p_what) {
delete_rect = Rect2();
}
} 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));
}
}
}
}

Expand Down Expand Up @@ -810,6 +822,9 @@ void EditorProperty::set_label_reference(Control *p_control) {

void EditorProperty::set_bottom_editor(Control *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 {
Expand Down Expand Up @@ -4087,6 +4102,9 @@ void EditorInspector::_notification(int p_what) {

case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
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")) {
EditorPropertyNameProcessor::Style style = EditorPropertyNameProcessor::get_settings_style();
Expand Down
2 changes: 2 additions & 0 deletions editor/editor_inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ class EditorProperty : public Container {
void _update_pin_flags();

protected:
bool has_borders = false;

void _notification(int p_what);
static void _bind_methods();
virtual void _set_read_only(bool p_read_only);
Expand Down
9 changes: 1 addition & 8 deletions editor/editor_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3364,8 +3364,6 @@ void EditorPropertyResource::update_property() {
EditorNode::get_singleton()->hide_unused_editors();
opened_editor = false;
}

_update_property_bg();
}
}
}
Expand Down Expand Up @@ -3422,12 +3420,6 @@ bool EditorPropertyResource::is_colored(ColorationMode p_mode) {

void EditorPropertyResource::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
if (EditorThemeManager::is_generated_theme_outdated()) {
_update_property_bg();
}
} break;

case NOTIFICATION_EXIT_TREE: {
const EditorInspector *ei = get_parent_inspector();
if (ei && !ei->is_main_editor_inspector()) {
Expand All @@ -3439,6 +3431,7 @@ void EditorPropertyResource::_notification(int p_what) {

EditorPropertyResource::EditorPropertyResource() {
use_sub_inspector = bool(EDITOR_GET("interface/inspector/open_resources_in_current_inspector"));
has_borders = true;
}

////////////// DEFAULT PLUGIN //////////////////////
Expand Down
16 changes: 3 additions & 13 deletions editor/editor_properties_array_dict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,6 @@ void EditorPropertyArray::update_property() {
paginator->connect("page_changed", callable_mp(this, &EditorPropertyArray::_page_changed));
vbox->add_child(paginator);

_update_property_bg();

for (int i = 0; i < page_length; i++) {
_create_new_property_slot();
}
Expand Down Expand Up @@ -454,7 +452,6 @@ void EditorPropertyArray::update_property() {
memdelete(container);
button_add_item = nullptr;
container = nullptr;
_update_property_bg();
slots.clear();
}
}
Expand Down Expand Up @@ -628,10 +625,6 @@ Node *EditorPropertyArray::get_base_node() {
void EditorPropertyArray::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED:
if (EditorThemeManager::is_generated_theme_outdated()) {
_update_property_bg();
}
[[fallthrough]];
case NOTIFICATION_ENTER_TREE: {
change_type->clear();
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
Expand Down Expand Up @@ -851,6 +844,7 @@ EditorPropertyArray::EditorPropertyArray() {
subtype = Variant::NIL;
subtype_hint = PROPERTY_HINT_NONE;
subtype_hint_string = "";
has_borders = true;
}

///////////////////// DICTIONARY ///////////////////////////
Expand Down Expand Up @@ -1000,7 +994,6 @@ void EditorPropertyDictionary::update_property() {
paginator = memnew(EditorPaginator);
paginator->connect("page_changed", callable_mp(this, &EditorPropertyDictionary::_page_changed));
vbox->add_child(paginator);
_update_property_bg();

for (int i = 0; i < page_length; i++) {
_create_new_property_slot(slots.size());
Expand Down Expand Up @@ -1075,7 +1068,6 @@ void EditorPropertyDictionary::update_property() {
memdelete(container);
button_add_item = nullptr;
container = nullptr;
_update_property_bg();
add_panel = nullptr;
slots.clear();
}
Expand All @@ -1089,10 +1081,6 @@ void EditorPropertyDictionary::_object_id_selected(const StringName &p_property,
void EditorPropertyDictionary::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED:
if (EditorThemeManager::is_generated_theme_outdated()) {
_update_property_bg();
}
[[fallthrough]];
case NOTIFICATION_ENTER_TREE: {
change_type->clear();
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
Expand All @@ -1109,6 +1097,7 @@ void EditorPropertyDictionary::_notification(int p_what) {

if (button_add_item) {
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;
}
Expand Down Expand Up @@ -1166,6 +1155,7 @@ EditorPropertyDictionary::EditorPropertyDictionary() {
add_child(change_type);
change_type->connect("id_pressed", callable_mp(this, &EditorPropertyDictionary::_change_type_menu));
changing_type_index = -1;
has_borders = true;
}

///////////////////// LOCALIZABLE STRING ///////////////////////////
Expand Down

0 comments on commit 4fe9764

Please sign in to comment.