Skip to content

Commit

Permalink
Merge pull request #1447 from dsnopek/avoid-double-postinitialize
Browse files Browse the repository at this point in the history
Fix NOTIFICATION_POSTINITIALIZE sent twice to native parent classes
  • Loading branch information
dsnopek authored May 17, 2024
2 parents e4a4d76 + 06373ce commit b697ba8
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 @@ -89,6 +89,7 @@ class Wrapped {
::godot::List<::godot::PropertyInfo> plist_owned;

void _postinitialize();
virtual void _notificationv(int32_t p_what, bool p_reversed = false) {}

Wrapped(const StringName p_godot_class);
Wrapped(GodotObject *p_godot_object);
Expand Down Expand Up @@ -374,6 +375,11 @@ public:
_gde_binding_reference_callback, \
}; \
\
protected: \
virtual void _notificationv(int32_t p_what, bool p_reversed = false) override { \
m_class::notification_bind(this, p_what, p_reversed); \
} \
\
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 b697ba8

Please sign in to comment.