Merge pull request #76204 from YuriSizov/editor-cleanup-deleted-node-history
Fix cleaning up inspector and history when deleting multiple nodes at once
This commit is contained in:
commit
afbefae7b4
1 changed files with 40 additions and 16 deletions
|
@ -39,6 +39,7 @@
|
||||||
#include "editor/editor_plugin.h"
|
#include "editor/editor_plugin.h"
|
||||||
#include "editor/editor_scale.h"
|
#include "editor/editor_scale.h"
|
||||||
#include "editor/editor_undo_redo_manager.h"
|
#include "editor/editor_undo_redo_manager.h"
|
||||||
|
#include "editor/multi_node_edit.h"
|
||||||
#include "editor/plugins/script_editor_plugin.h"
|
#include "editor/plugins/script_editor_plugin.h"
|
||||||
#include "scene/resources/packed_scene.h"
|
#include "scene/resources/packed_scene.h"
|
||||||
|
|
||||||
|
@ -48,10 +49,29 @@ void EditorSelectionHistory::cleanup_history() {
|
||||||
|
|
||||||
for (int j = 0; j < history[i].path.size(); j++) {
|
for (int j = 0; j < history[i].path.size(); j++) {
|
||||||
if (!history[i].path[j].ref.is_null()) {
|
if (!history[i].path[j].ref.is_null()) {
|
||||||
|
// If the node is a MultiNodeEdit node, examine it and see if anything is missing from it.
|
||||||
|
Ref<MultiNodeEdit> multi_node_edit = history[i].path[j].ref;
|
||||||
|
if (multi_node_edit.is_valid()) {
|
||||||
|
Node *root = EditorNode::get_singleton()->get_edited_scene();
|
||||||
|
if (root) {
|
||||||
|
for (int k = 0; k < multi_node_edit->get_node_count(); k++) {
|
||||||
|
NodePath np = multi_node_edit->get_node(k);
|
||||||
|
Node *multi_node_selected_node = root->get_node_or_null(np);
|
||||||
|
if (!multi_node_selected_node) {
|
||||||
|
fail = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fail = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// Reference is not null - object still alive.
|
// Reference is not null - object still alive.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fail) {
|
||||||
Object *obj = ObjectDB::get_instance(history[i].path[j].object);
|
Object *obj = ObjectDB::get_instance(history[i].path[j].object);
|
||||||
if (obj) {
|
if (obj) {
|
||||||
Node *n = Object::cast_to<Node>(obj);
|
Node *n = Object::cast_to<Node>(obj);
|
||||||
|
@ -66,8 +86,12 @@ void EditorSelectionHistory::cleanup_history() {
|
||||||
} // Else: object not valid - not alive.
|
} // Else: object not valid - not alive.
|
||||||
|
|
||||||
fail = true;
|
fail = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fail) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (fail) {
|
if (fail) {
|
||||||
history.remove_at(i);
|
history.remove_at(i);
|
||||||
|
|
Loading…
Reference in a new issue