Merge pull request #940 from touilleMan/fix-get_property_list-stringname-lifetime
Fix lifetime of StringName objects returned by Wrapped::_get_property_listpull/897/head
commit
4c5cfe3876
|
@ -69,6 +69,7 @@ protected:
|
||||||
static GDNativeBool property_get_revert_bind(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret) { return false; }
|
static GDNativeBool property_get_revert_bind(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret) { return false; }
|
||||||
static void to_string_bind(GDExtensionClassInstancePtr p_instance, GDNativeBool *r_is_valid, GDNativeStringPtr r_out) {}
|
static void to_string_bind(GDExtensionClassInstancePtr p_instance, GDNativeBool *r_is_valid, GDNativeStringPtr r_out) {}
|
||||||
|
|
||||||
|
::godot::List<::godot::PropertyInfo> plist_owned;
|
||||||
GDNativePropertyInfo *plist = nullptr;
|
GDNativePropertyInfo *plist = nullptr;
|
||||||
uint32_t plist_size = 0;
|
uint32_t plist_size = 0;
|
||||||
|
|
||||||
|
@ -209,12 +210,11 @@ public:
|
||||||
if (p_instance && m_class::_get_get_property_list()) { \
|
if (p_instance && m_class::_get_get_property_list()) { \
|
||||||
if (m_class::_get_get_property_list() != m_inherits::_get_get_property_list()) { \
|
if (m_class::_get_get_property_list() != m_inherits::_get_get_property_list()) { \
|
||||||
m_class *cls = reinterpret_cast<m_class *>(p_instance); \
|
m_class *cls = reinterpret_cast<m_class *>(p_instance); \
|
||||||
::godot::List<::godot::PropertyInfo> list; \
|
ERR_FAIL_COND_V_MSG(!cls->plist_owned.is_empty() || cls->plist != nullptr || cls->plist_size != 0, nullptr, "Internal error, property list was not freed by engine!"); \
|
||||||
cls->_get_property_list(&list); \
|
cls->_get_property_list(&cls->plist_owned); \
|
||||||
ERR_FAIL_COND_V_MSG(cls->plist != nullptr || cls->plist_size != 0, nullptr, "Internal error, property list was not freed by engine!"); \
|
cls->plist = reinterpret_cast<GDNativePropertyInfo *>(memalloc(sizeof(GDNativePropertyInfo) * cls->plist_owned.size())); \
|
||||||
cls->plist = reinterpret_cast<GDNativePropertyInfo *>(memalloc(sizeof(GDNativePropertyInfo) * list.size())); \
|
|
||||||
cls->plist_size = 0; \
|
cls->plist_size = 0; \
|
||||||
for (const ::godot::PropertyInfo &E : list) { \
|
for (const ::godot::PropertyInfo &E : cls->plist_owned) { \
|
||||||
cls->plist[cls->plist_size].type = static_cast<GDNativeVariantType>(E.type); \
|
cls->plist[cls->plist_size].type = static_cast<GDNativeVariantType>(E.type); \
|
||||||
cls->plist[cls->plist_size].name = E.name._native_ptr(); \
|
cls->plist[cls->plist_size].name = E.name._native_ptr(); \
|
||||||
cls->plist[cls->plist_size].hint = E.hint; \
|
cls->plist[cls->plist_size].hint = E.hint; \
|
||||||
|
@ -239,6 +239,7 @@ public:
|
||||||
memfree(cls->plist); \
|
memfree(cls->plist); \
|
||||||
cls->plist = nullptr; \
|
cls->plist = nullptr; \
|
||||||
cls->plist_size = 0; \
|
cls->plist_size = 0; \
|
||||||
|
cls->plist_owned.clear(); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
|
Loading…
Reference in New Issue