Fix premature theme item access in editor tools

This commit is contained in:
Yuri Sizov
2023-04-03 18:01:11 +02:00
parent e401540264
commit 9b500ab53c
12 changed files with 121 additions and 58 deletions

View File

@@ -234,7 +234,9 @@ TreeItem *EditorPerformanceProfiler::_get_monitor_base(const StringName &p_base_
base->set_editable(0, false);
base->set_selectable(0, false);
base->set_expand_right(0, true);
base->set_custom_font(0, get_theme_font(SNAME("bold"), SNAME("EditorFonts")));
if (is_inside_tree()) {
base->set_custom_font(0, get_theme_font(SNAME("bold"), SNAME("EditorFonts")));
}
base_map.insert(p_base_name, base);
return base;
}
@@ -368,6 +370,16 @@ List<float> *EditorPerformanceProfiler::get_monitor_data(const StringName &p_nam
return nullptr;
}
void EditorPerformanceProfiler::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
for (KeyValue<StringName, TreeItem *> &E : base_map) {
E.value->set_custom_font(0, get_theme_font(SNAME("bold"), SNAME("EditorFonts")));
}
} break;
}
}
EditorPerformanceProfiler::EditorPerformanceProfiler() {
set_name(TTR("Monitors"));
set_split_offset(340 * EDSCALE);

View File

@@ -79,6 +79,9 @@ private:
TreeItem *_create_monitor_item(const StringName &p_monitor_name, TreeItem *p_base);
void _marker_input(const Ref<InputEvent> &p_event);
protected:
void _notification(int p_what);
public:
void reset();
void update_monitors(const Vector<StringName> &p_names);