godotengine / godotengine/godot-cpp

A problem with the Ref

Open
#343 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.7k
Forks
809
Avg merge
1d 3h
Merged PRs (30d)
8

Description

Bare minimum of the file `ai_script.cpp`
```
void AIScript::_init() {
_enabled = true;
_source = Dictionary();
}

void AIScript::setSourceCode(String &p_source) {
Ref res = JSON::get_singleton()->parse(p_source);
if (res->get_error() == Error::OK) {
_source = res->get_result();
emit_signal("changed");
}
}

void AIScript::set_enabled(bool p_value) {
............
```

while `ai_script.h` is
```
class AIScript : public Resource {
GODOT_CLASS(AIScript, Resource)

public:
AIScript() {}

void _init();
Variant setSourceCode(String &p_source);
```

And when I call `Ref scr = AIScript::_new()` following happens

```
handle_crash: Program crashed with signal 11
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x46470) [0x7f7751676470] (??:0)
[2] godot() [0x2c39b50] (/home/rameshravone/Works/godot/./core/safe_refcount.h:107)
[3] godot() [0x2c39b0b] (/home/rameshravone/Works/godot/core/reference.cpp:37)
[4] godot() [0x2c3ade8] (/home/rameshravone/Works/godot/./core/method_ptrcall.h:104)
[5] /home/rameshravone/Works/GodotWorkspace/GDNative/TestBlank/demo/addons/test/libgodotai.so(+0x11f18a) [0x7f772c8b418a] (??:0)
[6] godot::Ref::ref_pointer(godot::AIScript*) (??:0)
[7] SimpleClass::method(godot::Variant) (??:0)
[8] void godot::_WrappedMethod::apply<0>(godot::Variant*, SimpleClass*, godot::Variant**, godot::__Sequence<0>) (??:0)
[9] godot_variant godot::__wrapped_method(void*, void*, void*, int, godot_variant**) (??:0)
[10] godot() [0x961a42] (/home/rameshravone/Works/godot/modules/gdnative/nativescript/nativescript.cpp:719)
[11] godot() [0x2c02311] (/home/rameshravone/Works/godot/core/object.cpp:?)
[12] godot() [0x2cc9167] (/home/rameshravone/Works/godot/core/variant_call.cpp:?)
[13] godot() [0x5826f3] (/home/rameshravone/Works/godot/modules/gdscript/gdscript.h:435)
[14] godot() [0x50c419] (/home/rameshravone/Works/godot/./core/variant.h:418)
[15] godot() [0x202ecbb] (/home/rameshravone/Works/godot/scene/3d/spatial.h:54)
[16] godot() [0x2bfec5e] (/home/rameshravone/Works/godot/core/object.cpp:933)
[17] godot() [0x1b5af4d] (/home/rameshravone/Works/godot/./scene/scene_string_names.h:52)
[18] godot() [0x1b5af0b] (/home/rameshravone/Works/godot/scene/main/node.cpp:186)
[19] godot() [0x1b600fa] (/home/rameshravone/Works/godot/scene/main/node.cpp:2553)
[20] godot() [0x1b915ea] (/home/rameshravone/Works/godot/scene/main/scene_tree.cpp:465)
[21] godot() [0x456440] (/home/rameshravone/Works/godot/platform/x11/os_x11.cpp:3253)
[22] godot(main+0x99) [0x447c29] (/home/rameshravone/Works/godot/platform/x11/godot_x11.cpp:57)
[23] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7f77516571e3] (??:0)
[24] godot() [0x447ace] (??:?)
-- END OF BACKTRACE --
Aborted (core dumped)
make: *** [Makefile:10: rungame] Error 134
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.