summaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2024-05-07 12:54:35 -0500
committerDavid Snopek <dsnopek@gmail.com>2024-05-10 19:51:31 -0500
commit88df025aa0ab92ed176f91dd835c004fa26f0ed0 (patch)
tree61c4a3c454986d3723a095ff46f91f0f3eecafb0 /test/src
parent85172dad1bd3cfed8cf8b4c2826f34cfe211af05 (diff)
downloadredot-cpp-88df025aa0ab92ed176f91dd835c004fa26f0ed0.tar.gz
Clean up instance bindings for engine singletons to prevent crash
Diffstat (limited to 'test/src')
-rw-r--r--test/src/example.cpp7
-rw-r--r--test/src/example.h2
2 files changed, 9 insertions, 0 deletions
diff --git a/test/src/example.cpp b/test/src/example.cpp
index 3ec8bca..78d7062 100644
--- a/test/src/example.cpp
+++ b/test/src/example.cpp
@@ -11,6 +11,7 @@
#include <godot_cpp/classes/label.hpp>
#include <godot_cpp/classes/multiplayer_api.hpp>
#include <godot_cpp/classes/multiplayer_peer.hpp>
+#include <godot_cpp/classes/os.hpp>
#include <godot_cpp/variant/utility_functions.hpp>
using namespace godot;
@@ -239,6 +240,8 @@ void Example::_bind_methods() {
GDVIRTUAL_BIND(_do_something_virtual, "name", "value");
ClassDB::bind_method(D_METHOD("test_virtual_implemented_in_script"), &Example::test_virtual_implemented_in_script);
+ ClassDB::bind_method(D_METHOD("test_use_engine_singleton"), &Example::test_use_engine_singleton);
+
ClassDB::bind_static_method("Example", D_METHOD("test_static", "a", "b"), &Example::test_static);
ClassDB::bind_static_method("Example", D_METHOD("test_static2"), &Example::test_static2);
@@ -671,6 +674,10 @@ String Example::test_virtual_implemented_in_script(const String &p_name, int p_v
return "Unimplemented";
}
+String Example::test_use_engine_singleton() const {
+ return OS::get_singleton()->get_name();
+}
+
void ExampleRuntime::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_prop_value", "value"), &ExampleRuntime::set_prop_value);
ClassDB::bind_method(D_METHOD("get_prop_value"), &ExampleRuntime::get_prop_value);
diff --git a/test/src/example.h b/test/src/example.h
index 0ad9493..1af4e5f 100644
--- a/test/src/example.h
+++ b/test/src/example.h
@@ -186,6 +186,8 @@ public:
GDVIRTUAL2R(String, _do_something_virtual, String, int);
String test_virtual_implemented_in_script(const String &p_name, int p_value);
+
+ String test_use_engine_singleton() const;
};
VARIANT_ENUM_CAST(Example::Constants);