Skip to content

Commit f7b9a6a

Browse files
committed
Merge pull request godotengine#100091 from AeioMuch/fix_nodepath_in_history
Add missing cleanup of editor history & set appropriate class icon for object in it
2 parents 0c76360 + 96e59b9 commit f7b9a6a

File tree

5 files changed

+33
-35
lines changed

5 files changed

+33
-35
lines changed

editor/editor_node.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4886,11 +4886,29 @@ Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String
48864886
ERR_FAIL_NULL_V_MSG(p_object, nullptr, "Object cannot be null.");
48874887

48884888
Ref<Script> scr = p_object->get_script();
4889+
4890+
if (Object::cast_to<EditorDebuggerRemoteObject>(p_object)) {
4891+
String class_name;
4892+
if (scr.is_valid()) {
4893+
class_name = scr->get_global_name();
4894+
4895+
if (class_name.is_empty()) {
4896+
// If there is no class_name in this script we just take the script path.
4897+
class_name = scr->get_path();
4898+
}
4899+
}
4900+
return get_class_icon(class_name.is_empty() ? Object::cast_to<EditorDebuggerRemoteObject>(p_object)->type_name : class_name, p_fallback);
4901+
}
4902+
48894903
if (scr.is_null() && p_object->is_class("Script")) {
48904904
scr = p_object;
48914905
}
48924906

4893-
return _get_class_or_script_icon(p_object->get_class(), scr, p_fallback);
4907+
if (Object::cast_to<MultiNodeEdit>(p_object)) {
4908+
return get_class_icon(Object::cast_to<MultiNodeEdit>(p_object)->get_edited_class_name(), p_fallback);
4909+
} else {
4910+
return _get_class_or_script_icon(p_object->get_class(), scr, p_fallback);
4911+
}
48944912
}
48954913

48964914
Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p_fallback) {

editor/editor_node.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,8 @@ class EditorNode : public Node {
832832
};
833833

834834
struct SceneEditorDataEntry {
835-
bool is_editable;
836-
bool is_display_folded;
835+
bool is_editable = false;
836+
bool is_display_folded = false;
837837
};
838838

839839
HashMap<int, SceneModificationsEntry> scenes_modification_table;

editor/gui/editor_object_selector.cpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@
3030

3131
#include "editor_object_selector.h"
3232

33-
#include "editor/debugger/editor_debugger_inspector.h"
3433
#include "editor/editor_data.h"
3534
#include "editor/editor_node.h"
3635
#include "editor/editor_string_names.h"
37-
#include "editor/multi_node_edit.h"
3836
#include "editor/themes/editor_scale.h"
3937
#include "scene/gui/margin_container.h"
4038

@@ -129,25 +127,7 @@ void EditorObjectSelector::update_path() {
129127
continue;
130128
}
131129

132-
Ref<Texture2D> obj_icon;
133-
if (Object::cast_to<MultiNodeEdit>(obj)) {
134-
obj_icon = EditorNode::get_singleton()->get_class_icon(Object::cast_to<MultiNodeEdit>(obj)->get_edited_class_name());
135-
} else if (Object::cast_to<EditorDebuggerRemoteObject>(obj)) {
136-
String class_name;
137-
Ref<Script> base_script = obj->get_script();
138-
if (base_script.is_valid()) {
139-
class_name = base_script->get_global_name();
140-
141-
if (class_name.is_empty()) {
142-
// If there is no class_name in this script we just take the script path.
143-
class_name = base_script->get_path();
144-
}
145-
}
146-
147-
obj_icon = EditorNode::get_singleton()->get_class_icon(class_name.is_empty() ? Object::cast_to<EditorDebuggerRemoteObject>(obj)->type_name : class_name);
148-
} else {
149-
obj_icon = EditorNode::get_singleton()->get_object_icon(obj);
150-
}
130+
Ref<Texture2D> obj_icon = EditorNode::get_singleton()->get_object_icon(obj);
151131

152132
if (obj_icon.is_valid()) {
153133
current_object_icon->set_texture(obj_icon);

editor/inspector_dock.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ Ref<Resource> InspectorDock::_get_current_resource() const {
316316

317317
void InspectorDock::_prepare_history() {
318318
EditorSelectionHistory *editor_history = EditorNode::get_singleton()->get_editor_selection_history();
319+
editor_history->cleanup_history();
319320

320321
int history_to = MAX(0, editor_history->get_history_len() - 25);
321322

@@ -505,6 +506,7 @@ void InspectorDock::clear() {
505506

506507
void InspectorDock::update(Object *p_object) {
507508
EditorSelectionHistory *editor_history = EditorNode::get_singleton()->get_editor_selection_history();
509+
508510
backward_button->set_disabled(editor_history->is_at_beginning());
509511
forward_button->set_disabled(editor_history->is_at_end());
510512

editor/scene_tree_dock.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,7 +2300,6 @@ void SceneTreeDock::_node_reparent(NodePath p_path, bool p_keep_global_xform) {
23002300
ERR_FAIL_NULL(new_parent);
23012301

23022302
List<Node *> selection = editor_selection->get_selected_node_list();
2303-
List<Node *> full_selection = editor_selection->get_full_selected_node_list();
23042303

23052304
if (selection.is_empty()) {
23062305
return; // Nothing to reparent.
@@ -2313,10 +2312,6 @@ void SceneTreeDock::_node_reparent(NodePath p_path, bool p_keep_global_xform) {
23132312
}
23142313

23152314
_do_reparent(new_parent, -1, nodes, p_keep_global_xform);
2316-
2317-
for (Node *E : full_selection) {
2318-
editor_selection->add_node(E);
2319-
}
23202315
}
23212316

23222317
void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, Vector<Node *> p_nodes, bool p_keep_global_xform) {
@@ -2509,12 +2504,20 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
25092504

25102505
perform_node_renames(nullptr, &path_renames);
25112506

2512-
undo_redo->commit_action();
2507+
undo_redo->add_do_method(editor_selection, "clear");
2508+
undo_redo->add_undo_method(editor_selection, "clear");
2509+
List<Node *> full_selection = editor_selection->get_full_selected_node_list();
2510+
for (Node *E : full_selection) {
2511+
undo_redo->add_do_method(editor_selection, "add_node", E);
2512+
undo_redo->add_undo_method(editor_selection, "add_node", E);
2513+
}
25132514

25142515
if (need_edit) {
25152516
EditorNode::get_singleton()->edit_current();
25162517
editor_selection->clear();
25172518
}
2519+
2520+
undo_redo->commit_action();
25182521
}
25192522

25202523
void SceneTreeDock::_script_created(Ref<Script> p_script) {
@@ -3653,7 +3656,6 @@ void SceneTreeDock::_nodes_dragged(const Array &p_nodes, NodePath p_to, int p_ty
36533656
}
36543657

36553658
List<Node *> selection = editor_selection->get_selected_node_list();
3656-
List<Node *> full_selection = editor_selection->get_full_selected_node_list();
36573659

36583660
if (selection.is_empty()) {
36593661
return; //nothing to reparent
@@ -3673,10 +3675,6 @@ void SceneTreeDock::_nodes_dragged(const Array &p_nodes, NodePath p_to, int p_ty
36733675

36743676
_normalize_drop(to_node, to_pos, p_type);
36753677
_do_reparent(to_node, to_pos, nodes, !Input::get_singleton()->is_key_pressed(Key::SHIFT));
3676-
3677-
for (Node *E : full_selection) {
3678-
editor_selection->add_node(E);
3679-
}
36803678
}
36813679

36823680
void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) {

0 commit comments

Comments
 (0)