Skip to content

Commit

Permalink
Refactor and remove excessive calls of NOTIFICATION_THEME_CHANGED
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronRecord committed Aug 25, 2022
1 parent 6d196c1 commit 74eb2a7
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 178 deletions.
8 changes: 7 additions & 1 deletion doc/classes/Control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,7 @@
</signal>
<signal name="theme_changed">
<description>
Emitted when the [constant NOTIFICATION_THEME_CHANGED] notification is sent.
</description>
</signal>
</signals>
Expand Down Expand Up @@ -1174,7 +1175,12 @@
Sent when the node loses focus.
</constant>
<constant name="NOTIFICATION_THEME_CHANGED" value="45">
Sent when the node's [member theme] changes, right before Godot redraws the control. Happens when you call one of the [code]add_theme_*_override[/code] methods.
Sent when the node needs to refresh its theme items. This happens in one of the following cases:
- The [member theme] property is changed on this node or any of its ancestors.
- The [member theme_type_variation] property is changed on this node.
- One of the node's theme property overrides is changed.
- The node enters the scene tree.
[b]Note:[/b] As an optimization, this notification won't be sent from changes that occur while this node is outside of the scene tree. Instead, all of the theme item updates can be applied at once when the node enters the scene tree.
</constant>
<constant name="NOTIFICATION_SCROLL_BEGIN" value="47">
Sent when this node is inside a [ScrollContainer] which has begun being scrolled.
Expand Down
9 changes: 8 additions & 1 deletion doc/classes/Window.xml
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@
</signal>
<signal name="theme_changed">
<description>
Emitted when the [member theme] is modified or changed to another [Theme].
Emitted when the [constant NOTIFICATION_THEME_CHANGED] notification is sent.
</description>
</signal>
<signal name="visibility_changed">
Expand All @@ -467,6 +467,13 @@
<constant name="NOTIFICATION_VISIBILITY_CHANGED" value="30">
Emitted when [Window]'s visibility changes, right before [signal visibility_changed].
</constant>
<constant name="NOTIFICATION_THEME_CHANGED" value="32">
Sent when the node needs to refresh its theme items. This happens in one of the following cases:
- The [member theme] property is changed on this node or any of its ancestors.
- The [member theme_type_variation] property is changed on this node.
- The node enters the scene tree.
[b]Note:[/b] As an optimization, this notification won't be sent from changes that occur while this node is outside of the scene tree. Instead, all of the theme item updates can be applied at once when the node enters the scene tree.
</constant>
<constant name="MODE_WINDOWED" value="0" enum="Mode">
Windowed mode, i.e. [Window] doesn't occupy whole screen (unless set to the size of the screen).
</constant>
Expand Down
5 changes: 5 additions & 0 deletions editor/editor_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ void EditorLog::_rebuild_log() {
}

void EditorLog::_add_log_line(LogMessage &p_message, bool p_replace_previous) {
if (!is_inside_tree()) {
// The log will be built all at once when it enters the tree and has its theme items.
return;
}

// Only add the message to the log if it passes the filters.
bool filter_active = type_filter_map[p_message.type]->is_active();
String search_text = search_box->get_text();
Expand Down
Loading

0 comments on commit 74eb2a7

Please sign in to comment.