Open SnailBones opened 5 years ago
The problem with structuring it like this is that Godot looses the ability to reference count the object and destroys it before its ready.
You need to define next_state as a Ref
Ref<Grid> next_state;
...
// instantiate our object properly initialising our refcount.
next_state.instance()
...
Ref<Grid> Model::get_state() {
return next_state;
}
When you did Ref<Grid> ref = Ref<Grid>(next_state);
you are creating a new reference counter object with reference count set to 1. Once that goes out of scope next_state will be destructed even though you are still using it, hence the crash.
Is this issue fixed? (tbh there are others like this which don't seem to be issues with Godot-Cpp but more like questions/troubleshootings which are still hanging around)
I have one GDNative object listed as a property of another. When returning a pointer to the property or casting said pointer to a reference, the engine crashes.
However, if I initialize a new instance and copy the values over, it works as intended. Unfortunately, my workaround creates a drain on performance. Perhaps Godot only has access to the heap?
C++ code:
Backtrace: