Fix memdelete() of Object using pointer to secondary parent class#88688
Fix memdelete() of Object using pointer to secondary parent class#88688dsnopek wants to merge 1 commit intogodotengine:masterfrom
memdelete() of Object using pointer to secondary parent class#88688Conversation
|
Given that the class still needs to opt in to this new core behavior with If we could make it automagical so this pattern works out of the box, the core approach would make a lot of sense IMO (provided it doesn't add too much complexity or impact negatively the other, more common patterns). But that's just my non-expert opinion. I'd wait to get input from @reduz and @RandomShaper who might like this approach. That might take a while to assess, so in the short temr I suggest we merge #88689 (and this PR can then be rebased to undo the change for #88689 that wouldn't be needed if this approach is merged). |
|
Without having assessed personally the classes involved in the issue, this is my take:
|
It's possible to write the template to automagically detect the situation, but, unfortunately, it requires the full definition of
Understood! I guess I'll just close this one then :-) |
Fixes #88613
There is a pattern used in a very small number of places in Godot, in order to simulate "interfaces" (which C++ doesn't directly support).
Here's how it works:
Object(or some other ancestor ofObject) as the first parent class, and then extend the abstract class as a secondary parent classThis is used by a couple of classes in the OpenXR module:
OpenXRExtensionWrapperOpenXRGraphicsExtensionWrapper(which extends the previous one)OpenXRCompositionLayerProviderThis all works fine, except when you keep a reference to one of these types and then later try to
memdelete()it, which is done in the case ofOpenXRExtensionWrapperand is the source of the bug from issue #88613This PR allows developers to mark one of these interface classes using a new
IS_POSSIBLE_GDCLASS()macro, that will tellmemdelete()to do some additional work that will clean everything up correctly.Given how uncommon this pattern is in Godot, I could understand not wanting to accept this general change to
memdelete()and instead have the OpenXR implement its own bespoke solution. However, I thought I would propose it and see what folks thought :-)