summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2024-04-24 13:01:53 -0500
committerDavid Snopek <dsnopek@gmail.com>2024-04-24 13:22:19 -0500
commit06373ce1cf737a33d6a7b2b14cfe25ed729b9c48 (patch)
treefbb2f921cb89f3d3f71d3eec999f86a941b72802
parentad307e4b9ceb2efc40a238c19d37f41def4742d6 (diff)
downloadredot-cpp-06373ce1cf737a33d6a7b2b14cfe25ed729b9c48.tar.gz
Fix NOTIFICATION_POSTINITIALIZE sent twice to native parent class
-rw-r--r--include/godot_cpp/classes/wrapped.hpp6
-rw-r--r--src/classes/wrapped.cpp5
2 files changed, 7 insertions, 4 deletions
diff --git a/include/godot_cpp/classes/wrapped.hpp b/include/godot_cpp/classes/wrapped.hpp
index 97f9a6e..d5a718c 100644
--- a/include/godot_cpp/classes/wrapped.hpp
+++ b/include/godot_cpp/classes/wrapped.hpp
@@ -89,6 +89,7 @@ protected:
::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);
@@ -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.
diff --git a/src/classes/wrapped.cpp b/src/classes/wrapped.cpp
index ad0eefb..594cfef 100644
--- a/src/classes/wrapped.cpp
+++ b/src/classes/wrapped.cpp
@@ -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);
}
}