Godot Version
4.3-stable (double precision)
Question
I have a class that exposes a TypedArray of a custom resource type that I have exposed via to the editor. I can add and remove from the array just fine. But as soon as I try to edit a value inside the array it causes a User-mode data execution prevention (DEP) violation
which I have no idea how to fix.
It’s apparently a Windows exception when you access memory you shouldn’t but I am not sure what memory it is accessing that I shouldn’t or why.
I’d appreciate a second pair of eyes on my code:
// Entity.hpp
class Entity3D final : public godot::Node3D {
GDCLASS(Entity3D, godot::Node3D)
public:
Entity3D() = default;
~Entity3D() override = default;
auto get_godot_components() const -> godot::TypedArray<Component>;
auto set_godot_components(const godot::TypedArray<Component>& component) -> void;
protected:
static auto _bind_methods() -> void;
private:
godot::TypedArray<Component> _components;
};
// Entity.cpp
auto Entity3D::get_godot_components() const -> TypedArray<Component> { return _components; }
auto Entity3D::set_godot_components(const TypedArray<Component>& component) -> void { _components = component; }
auto Entity3D::_bind_methods() -> void {
ClassDB::bind_method(D_METHOD("get_godot_components"), &Entity3D::get_godot_components);
ClassDB::bind_method(D_METHOD("set_godot_components", "component"), &Entity3D::set_godot_components);
String hint_string = String::num(Variant::OBJECT) + "/" + String::num(PROPERTY_HINT_RESOURCE_TYPE) + ":Component";
ClassDB::add_property("Entity3D",PropertyInfo(Variant::ARRAY,"_components",PROPERTY_HINT_TYPE_STRING,hint_string),
"set_godot_components","get_godot_components");
}