Merge pull request #58950 from akien-mga/fix-undoredo-argcount

This commit is contained in:
Rémi Verschelde 2022-03-09 22:59:54 +01:00 committed by GitHub
commit 450ebaab9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View file

@ -312,18 +312,18 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
switch (op.type) { switch (op.type) {
case Operation::TYPE_METHOD: { case Operation::TYPE_METHOD: {
int argc = op.args.size();
Vector<const Variant *> argptrs; Vector<const Variant *> argptrs;
argptrs.resize(op.args.size()); argptrs.resize(argc);
int argc = 0;
for (int i = 0; i < op.args.size(); i++) { for (int i = 0; i < argc; i++) {
argptrs.write[i] = &op.args[i]; argptrs.write[i] = &op.args[i];
} }
Callable::CallError ce; Callable::CallError ce;
obj->callp(op.name, (const Variant **)argptrs.ptr(), argc, ce); obj->callp(op.name, (const Variant **)argptrs.ptr(), argc, ce);
if (ce.error != Callable::CallError::CALL_OK) { if (ce.error != Callable::CallError::CALL_OK) {
ERR_PRINT("Error calling method from signal '" + String(op.name) + "': " + Variant::get_call_error_text(obj, op.name, (const Variant **)argptrs.ptr(), argc, ce)); ERR_PRINT("Error calling UndoRedo method operation '" + String(op.name) + "': " + Variant::get_call_error_text(obj, op.name, (const Variant **)argptrs.ptr(), argc, ce));
} }
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
Resource *res = Object::cast_to<Resource>(obj); Resource *res = Object::cast_to<Resource>(obj);
@ -334,7 +334,7 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
#endif #endif
if (method_callback) { if (method_callback) {
method_callback(method_callbck_ud, obj, op.name, (const Variant **)argptrs.ptr(), argc); method_callback(method_callback_ud, obj, op.name, (const Variant **)argptrs.ptr(), argc);
} }
} break; } break;
case Operation::TYPE_PROPERTY: { case Operation::TYPE_PROPERTY: {
@ -432,7 +432,7 @@ void UndoRedo::set_commit_notify_callback(CommitNotifyCallback p_callback, void
void UndoRedo::set_method_notify_callback(MethodNotifyCallback p_method_callback, void *p_ud) { void UndoRedo::set_method_notify_callback(MethodNotifyCallback p_method_callback, void *p_ud) {
method_callback = p_method_callback; method_callback = p_method_callback;
method_callbck_ud = p_ud; method_callback_ud = p_ud;
} }
void UndoRedo::set_property_notify_callback(PropertyNotifyCallback p_property_callback, void *p_ud) { void UndoRedo::set_property_notify_callback(PropertyNotifyCallback p_property_callback, void *p_ud) {

View file

@ -92,7 +92,7 @@ private:
CommitNotifyCallback callback = nullptr; CommitNotifyCallback callback = nullptr;
void *callback_ud = nullptr; void *callback_ud = nullptr;
void *method_callbck_ud = nullptr; void *method_callback_ud = nullptr;
void *prop_callback_ud = nullptr; void *prop_callback_ud = nullptr;
MethodNotifyCallback method_callback = nullptr; MethodNotifyCallback method_callback = nullptr;