Fix crash on virtual method calls#1404
Conversation
dsnopek
left a comment
There was a problem hiding this comment.
Thanks!
Could do this on the engine side but as we seem to universally assume pointers are valid for these calls on the engine side, so this ensures it works correctly regardless
This logic makes sense to me. Looking at the existing gdextension_variant_call() function in the engine, it also takes a GDExtensionUninitializedVariantPtr r_return which must always point to valid memory (ie it can't be nullptr). And, so having gdextension_object_call_script_method() work in the same way would be consistent with that.
The downside is that we're initializing a Variant that won't ever be used, but there's other ways around that we could explore in the future (such as using uninitialized memory from the stack), and that's something we could take advantage of through out godot-cpp, since there's other places we're doing this as well - which would be best explored in a different issue/PR.
Could do this on the engine side but as we seem to universally assume pointers are valid for these calls on the engine side, so this ensures it works correctly regardless