Godot Engine – Multi-platform 2D and 3D game engine
Allow UndoRedo without object
kobewia507395b72fb
diff --git a/core/object/undo_redo.cpp b/core/object/undo_redo.cppindex a468426f630..52960620c40 100644--- a/core/object/undo_redo.cpp+++ b/core/object/undo_redo.cpp@@ -351,14 +351,14 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *r_elements, boofor (; r_elements; r_elements = r_elements->next()) {Operation &op = r_elements->get();-Object *obj = ObjectDB::get_instance(op.object);- if (!obj) { //may have been deleted and this is fine- continue;- }switch (op.type) {case Operation::TYPE_METHOD: {+ if (!op.callable.is_valid()) {+ continue;+ }+if (p_execute) {Callable::CallError ce;Variant ret;@@ -374,7 +374,7 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *r_elements, boo#endif}- if (method_callback) {+ if (method_callback && obj) {Vector<Variant> binds;if (op.callable.is_custom()) {CallableCustomBind *ccb = dynamic_cast<CallableCustomBind *>(op.callable.get_custom());@@ -397,6 +397,9 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *r_elements, boo}} break;case Operation::TYPE_PROPERTY: {+ if (!obj) { // May have been deleted and this is fine.+ continue;+ }if (p_execute) {obj->set(op.name, op.value);#ifdef TOOLS_ENABLED@@ -412,7 +415,7 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *r_elements, boo}} break;case Operation::TYPE_REFERENCE: {- //do nothing+ // Do nothing.} break;}}