Skip to content

Commit b697ba8

Browse files
authored
Merge pull request #1447 from dsnopek/avoid-double-postinitialize
Fix NOTIFICATION_POSTINITIALIZE sent twice to native parent classes
2 parents e4a4d76 + 06373ce commit b697ba8

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

include/godot_cpp/classes/wrapped.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class Wrapped {
8989
::godot::List<::godot::PropertyInfo> plist_owned;
9090

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

9394
Wrapped(const StringName p_godot_class);
9495
Wrapped(GodotObject *p_godot_object);
@@ -374,6 +375,11 @@ public:
374375
_gde_binding_reference_callback, \
375376
}; \
376377
\
378+
protected: \
379+
virtual void _notificationv(int32_t p_what, bool p_reversed = false) override { \
380+
m_class::notification_bind(this, p_what, p_reversed); \
381+
} \
382+
\
377383
private:
378384

379385
// Don't use this for your classes, use GDCLASS() instead.

src/classes/wrapped.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ void Wrapped::_postinitialize() {
5151
}
5252
godot::internal::gdextension_interface_object_set_instance_binding(_owner, godot::internal::token, this, _get_bindings_callbacks());
5353
if (extension_class) {
54-
Object *obj = dynamic_cast<Object *>(this);
55-
if (obj) {
56-
obj->notification(Object::NOTIFICATION_POSTINITIALIZE);
57-
}
54+
_notificationv(Object::NOTIFICATION_POSTINITIALIZE);
5855
}
5956
}
6057

0 commit comments

Comments
 (0)