Skip to content

Commit

Permalink
Move signal from SceneTree to EditorNode
Browse files Browse the repository at this point in the history
According to sourcegraph, users only used it wrongly to do what "update_configuration_info"
does for you anyway.
  • Loading branch information
RedMser committed May 16, 2024
1 parent b270efb commit 0ad0b93
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 19 deletions.
10 changes: 8 additions & 2 deletions core/io/resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
#include "core/os/os.h"
#include "scene/main/node.h" //only so casting works

#ifdef TOOLS_ENABLED
#include "editor/editor_node.h"
#include "editor/editor_string_names.h"
#endif // TOOLS_ENABLED

#include <stdio.h>

void Resource::emit_changed() {
Expand Down Expand Up @@ -536,8 +541,9 @@ Array Resource::get_configuration_info() const {

void Resource::update_configuration_info() {
#ifdef TOOLS_ENABLED
// REDMSER TODO: Signal has to be moved elsewhere. It doesn't even belong in SceneTree due to being editor-centric... EditorNode perhaps?
OS::get_singleton()->get_main_loop()->emit_signal(SceneStringName(configuration_info_changed), this);
if (Engine::get_singleton()->is_editor_hint()) {
EditorNode::get_singleton()->emit_signal(EditorStringName(configuration_info_changed), this);
}
#endif
}

Expand Down
8 changes: 1 addition & 7 deletions doc/classes/SceneTree.xml
Original file line number Diff line number Diff line change
Expand Up @@ -278,19 +278,13 @@
</member>
</members>
<signals>
<signal name="configuration_info_changed">
<param index="0" name="object" type="Object" />
<description>
Emitted when the [param object]'s [code]update_configuration_info[/code] method is called. Only emitted in the editor.
</description>
</signal>
<signal name="node_added">
<param index="0" name="node" type="Node" />
<description>
Emitted when the [param node] enters this tree.
</description>
</signal>
<signal name="node_configuration_warning_changed" deprecated="Use [signal configuration_info_changed] instead.">
<signal name="node_configuration_warning_changed" deprecated="This signal is no longer available. Call [code]update_configuration_info[/code] on a [Node] or [Resource] to notify the editor of configuration info changes.">
<param index="0" name="node" type="Node" />
<description>
Emitted when the [param node]'s [method Node.update_configuration_warnings] is called. Only emitted in the editor.
Expand Down
4 changes: 2 additions & 2 deletions editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4171,14 +4171,14 @@ void EditorInspector::_notification(int p_what) {
add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree")));
if (!sub_inspector) {
get_tree()->connect("node_removed", callable_mp(this, &EditorInspector::_node_removed));
get_tree()->connect(SceneStringName(configuration_info_changed), callable_mp(this, &EditorInspector::_configuration_info_changed));
EditorNode::get_singleton()->connect(EditorStringName(configuration_info_changed), callable_mp(this, &EditorInspector::_configuration_info_changed));
}
} break;

case NOTIFICATION_PREDELETE: {
if (!sub_inspector && is_inside_tree()) {
get_tree()->disconnect("node_removed", callable_mp(this, &EditorInspector::_node_removed));
get_tree()->disconnect(SceneStringName(configuration_info_changed), callable_mp(this, &EditorInspector::_configuration_info_changed));
EditorNode::get_singleton()->disconnect(EditorStringName(configuration_info_changed), callable_mp(this, &EditorInspector::_configuration_info_changed));
}
edit(nullptr);
} break;
Expand Down
1 change: 1 addition & 0 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6156,6 +6156,7 @@ void EditorNode::_bind_methods() {
ADD_SIGNAL(MethodInfo("scene_saved", PropertyInfo(Variant::STRING, "path")));
ADD_SIGNAL(MethodInfo("scene_changed"));
ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "path")));
ADD_SIGNAL(MethodInfo("configuration_info_changed", PropertyInfo(Variant::OBJECT, "object")));
}

static Node *_resource_get_edited_scene() {
Expand Down
1 change: 1 addition & 0 deletions editor/editor_string_names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
EditorStringNames *EditorStringNames::singleton = nullptr;

EditorStringNames::EditorStringNames() {
configuration_info_changed = StaticCString::create("configuration_info_changed");
Editor = StaticCString::create("Editor");
EditorFonts = StaticCString::create("EditorFonts");
EditorIcons = StaticCString::create("EditorIcons");
Expand Down
1 change: 1 addition & 0 deletions editor/editor_string_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class EditorStringNames {

_FORCE_INLINE_ static EditorStringNames *get_singleton() { return singleton; }

StringName configuration_info_changed;
StringName Editor;
StringName EditorFonts;
StringName EditorIcons;
Expand Down
4 changes: 2 additions & 2 deletions editor/gui/scene_tree_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ void SceneTreeEditor::_notification(int p_what) {
get_tree()->connect("tree_process_mode_changed", callable_mp(this, &SceneTreeEditor::_tree_process_mode_changed));
get_tree()->connect("node_removed", callable_mp(this, &SceneTreeEditor::_node_removed));
get_tree()->connect("node_renamed", callable_mp(this, &SceneTreeEditor::_node_renamed));
get_tree()->connect(SceneStringName(configuration_info_changed), callable_mp(this, &SceneTreeEditor::_config_info_changed));
EditorNode::get_singleton()->connect(EditorStringName(configuration_info_changed), callable_mp(this, &SceneTreeEditor::_config_info_changed));

tree->connect("item_collapsed", callable_mp(this, &SceneTreeEditor::_cell_collapsed));

Expand All @@ -890,7 +890,7 @@ void SceneTreeEditor::_notification(int p_what) {
get_tree()->disconnect("node_removed", callable_mp(this, &SceneTreeEditor::_node_removed));
get_tree()->disconnect("node_renamed", callable_mp(this, &SceneTreeEditor::_node_renamed));
tree->disconnect("item_collapsed", callable_mp(this, &SceneTreeEditor::_cell_collapsed));
get_tree()->disconnect(SceneStringName(configuration_info_changed), callable_mp(this, &SceneTreeEditor::_config_info_changed));
EditorNode::get_singleton()->disconnect(EditorStringName(configuration_info_changed), callable_mp(this, &SceneTreeEditor::_config_info_changed));
} break;

case NOTIFICATION_THEME_CHANGED: {
Expand Down
13 changes: 10 additions & 3 deletions scene/main/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
#include "scene/resources/packed_scene.h"
#include "viewport.h"

#ifdef TOOLS_ENABLED
#include "editor/editor_node.h"
#include "editor/editor_string_names.h"
#endif // TOOLS_ENABLED

#include <stdint.h>

int Node::orphan_node_count = 0;
Expand Down Expand Up @@ -3305,7 +3310,9 @@ void Node::update_configuration_warnings() {
}
if (get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_ancestor_of(this))) {
get_tree()->emit_signal(SceneStringName(node_configuration_warning_changed), this);
get_tree()->emit_signal(SceneStringName(configuration_info_changed), this);
if (Engine::get_singleton()->is_editor_hint()) {
EditorNode::get_singleton()->emit_signal(EditorStringName(configuration_info_changed), this);
}
}
#endif
}
Expand All @@ -3329,8 +3336,8 @@ void Node::update_configuration_info() {
if (!is_inside_tree()) {
return;
}
if (get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_ancestor_of(this))) {
get_tree()->emit_signal(SceneStringName(configuration_info_changed), this);
if (is_part_of_edited_scene()) {
EditorNode::get_singleton()->emit_signal(EditorStringName(configuration_info_changed), this);
}
#endif
}
Expand Down
1 change: 0 additions & 1 deletion scene/main/scene_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,6 @@ void SceneTree::_bind_methods() {
#ifndef DISABLE_DEPRECATED
ADD_SIGNAL(MethodInfo("node_configuration_warning_changed", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
#endif
ADD_SIGNAL(MethodInfo("configuration_info_changed", PropertyInfo(Variant::OBJECT, "object")));

ADD_SIGNAL(MethodInfo("process_frame"));
ADD_SIGNAL(MethodInfo("physics_frame"));
Expand Down
1 change: 0 additions & 1 deletion scene/scene_string_names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ SceneStringNames::SceneStringNames() {
#ifndef DISABLE_DEPRECATED
node_configuration_warning_changed = StaticCString::create("node_configuration_warning_changed");
#endif
configuration_info_changed = StaticCString::create("configuration_info_changed");

output = StaticCString::create("output");

Expand Down
1 change: 0 additions & 1 deletion scene/scene_string_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ class SceneStringNames {
#ifndef DISABLE_DEPRECATED
StringName node_configuration_warning_changed;
#endif
StringName configuration_info_changed;

StringName output;

Expand Down

0 comments on commit 0ad0b93

Please sign in to comment.