diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-05-28 15:49:26 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-05-28 15:49:26 +0200 |
commit | 4808f243125095ab1b271478ac031374c985df8a (patch) | |
tree | b1f0141822c647bc084f7c8ee535ad803febe898 /core/object/undo_redo.cpp | |
parent | 760e30a4deda8c1d95cc8c955775e9d260c04366 (diff) | |
parent | e88095ed8fbc7039c1724e51ee84f154fdf49305 (diff) | |
download | redot-engine-4808f243125095ab1b271478ac031374c985df8a.tar.gz |
Merge pull request #92350 from 4d49/undo-redo-fix-callable-name
Fix `UndoRedo` method name for custom `Callable`
Diffstat (limited to 'core/object/undo_redo.cpp')
-rw-r--r-- | core/object/undo_redo.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/core/object/undo_redo.cpp b/core/object/undo_redo.cpp index 4d67cd930e..0f7884305a 100644 --- a/core/object/undo_redo.cpp +++ b/core/object/undo_redo.cpp @@ -159,10 +159,11 @@ void UndoRedo::add_do_method(const Callable &p_callable) { do_op.ref = Ref<RefCounted>(Object::cast_to<RefCounted>(object)); } do_op.type = Operation::TYPE_METHOD; - do_op.name = p_callable.get_method(); - if (do_op.name == StringName()) { - // There's no `get_method()` for custom callables, so use `operator String()` instead. + // There's no `get_method()` for custom callables, so use `operator String()` instead. + if (p_callable.is_custom()) { do_op.name = static_cast<String>(p_callable); + } else { + do_op.name = p_callable.get_method(); } actions.write[current_action + 1].do_ops.push_back(do_op); @@ -190,10 +191,11 @@ void UndoRedo::add_undo_method(const Callable &p_callable) { } undo_op.type = Operation::TYPE_METHOD; undo_op.force_keep_in_merge_ends = force_keep_in_merge_ends; - undo_op.name = p_callable.get_method(); - if (undo_op.name == StringName()) { - // There's no `get_method()` for custom callables, so use `operator String()` instead. + // There's no `get_method()` for custom callables, so use `operator String()` instead. + if (p_callable.is_custom()) { undo_op.name = static_cast<String>(p_callable); + } else { + undo_op.name = p_callable.get_method(); } actions.write[current_action + 1].undo_ops.push_back(undo_op); |