Skip to content

Commit

Permalink
Fix NOTIFICATION_POSTINITIALIZE sent twice to native parent class
Browse files Browse the repository at this point in the history
(cherry picked from commit 06373ce)
  • Loading branch information
dsnopek committed May 17, 2024
1 parent 1ab42ec commit d0b0e68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 6 additions & 0 deletions include/godot_cpp/classes/wrapped.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class Wrapped {
uint32_t plist_size = 0;

void _postinitialize();
virtual void _notificationv(int32_t p_what) {}

Wrapped(const StringName p_godot_class);
Wrapped(GodotObject *p_godot_object);
Expand Down Expand Up @@ -328,6 +329,11 @@ public:
_gde_binding_reference_callback, \
}; \
\
protected: \
virtual void _notificationv(int32_t p_what) override { \
m_class::notification_bind(this, p_what); \
} \
\
private:

// Don't use this for your classes, use GDCLASS() instead.
Expand Down
5 changes: 1 addition & 4 deletions src/classes/wrapped.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ void Wrapped::_postinitialize() {
}
godot::internal::gdextension_interface_object_set_instance_binding(_owner, godot::internal::token, this, _get_bindings_callbacks());
if (extension_class) {
Object *obj = dynamic_cast<Object *>(this);
if (obj) {
obj->notification(Object::NOTIFICATION_POSTINITIALIZE);
}
_notificationv(Object::NOTIFICATION_POSTINITIALIZE);
}
}

Expand Down

0 comments on commit d0b0e68

Please sign in to comment.