Fix NOTIFICATION_POSTINITIALIZE sent twice to native parent class

(cherry picked from commit 06373ce1cf)
pull/1466/head
David Snopek 2024-04-24 13:01:53 -05:00
parent 1ab42ec6c5
commit 7b93607779
2 changed files with 7 additions and 4 deletions

View File

@ -76,6 +76,7 @@ protected:
uint32_t plist_size = 0; uint32_t plist_size = 0;
void _postinitialize(); void _postinitialize();
virtual void _notificationv(int32_t p_what) {}
Wrapped(const StringName p_godot_class); Wrapped(const StringName p_godot_class);
Wrapped(GodotObject *p_godot_object); Wrapped(GodotObject *p_godot_object);
@ -328,6 +329,11 @@ public:
_gde_binding_reference_callback, \ _gde_binding_reference_callback, \
}; \ }; \
\ \
protected: \
virtual void _notificationv(int32_t p_what) override { \
m_class::notification_bind(this, p_what); \
} \
\
private: private:
// Don't use this for your classes, use GDCLASS() instead. // Don't use this for your classes, use GDCLASS() instead.

View File

@ -51,10 +51,7 @@ void Wrapped::_postinitialize() {
} }
godot::internal::gdextension_interface_object_set_instance_binding(_owner, godot::internal::token, this, _get_bindings_callbacks()); godot::internal::gdextension_interface_object_set_instance_binding(_owner, godot::internal::token, this, _get_bindings_callbacks());
if (extension_class) { if (extension_class) {
Object *obj = dynamic_cast<Object *>(this); _notificationv(Object::NOTIFICATION_POSTINITIALIZE);
if (obj) {
obj->notification(Object::NOTIFICATION_POSTINITIALIZE);
}
} }
} }