Skip to content

Commit 5937067

Browse files
committed
Avoid !is_inside_world() error for camera frustum test
1 parent 6ed7506 commit 5937067

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

test/src/test_vararray_return.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,28 @@ fn test_vararray_return_crash() -> bool {
2020

2121
camera.set_frustum(5.0, Vector2::new(1.0, 2.0), 0.0, 1.0);
2222

23-
camera.get_frustum(); // this should not crash!
24-
25-
camera.free();
23+
// `get_frustum` now prints an error and returns a default value
24+
// if the camera is not inside the world
25+
unsafe {
26+
let camera = camera.into_shared();
27+
28+
gdnative::api::Engine::godot_singleton()
29+
.get_main_loop()
30+
.expect("missing MainLoop")
31+
.assume_safe()
32+
.cast::<SceneTree>()
33+
.expect("MainLoop is not a SceneTree")
34+
.current_scene()
35+
.expect("missing current scene")
36+
.assume_safe()
37+
.add_child(camera, false);
38+
39+
let camera = camera.assume_safe();
40+
41+
camera.get_frustum(); // this should not crash!
42+
43+
camera.queue_free();
44+
}
2645
})
2746
.is_ok();
2847

0 commit comments

Comments
 (0)