Skip to content

Commit d31d3f0

Browse files
committed
fix things
1 parent 0197fe4 commit d31d3f0

File tree

3 files changed

+53
-40
lines changed

3 files changed

+53
-40
lines changed

assets/tests/add_system/added_systems_run_in_parallel.lua

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,26 @@ digraph {
2727
node_2 [label="bevy_asset::assets::Assets<()>::asset_events"];
2828
node_3 [label="bevy_asset::assets::Assets<bevy_mod_scripting_asset::script_asset::ScriptAsset>::asset_events"];
2929
node_4 [label="bevy_mod_scripting_bindings::allocator::garbage_collector"];
30-
node_5 [label="script_integration_test_harness::dummy_before_post_update_system"];
31-
node_6 [label="script_integration_test_harness::dummy_post_update_system"];
32-
node_7 [label="on_test_post_update"];
33-
node_8 [label="custom_system_a"];
34-
node_9 [label="custom_system_b"];
35-
node_10 [label="SystemSet AssetEvents"];
36-
node_11 [label="SystemSet GarbageCollection"];
37-
node_12 [label="SystemSet ScriptSystem(custom_system_a)"];
38-
node_13 [label="SystemSet ScriptSystem(custom_system_b)"];
39-
node_0 -> node_10 [color=red, label="child of", arrowhead=diamond];
40-
node_1 -> node_10 [color=red, label="child of", arrowhead=diamond];
41-
node_2 -> node_10 [color=red, label="child of", arrowhead=diamond];
42-
node_3 -> node_10 [color=red, label="child of", arrowhead=diamond];
43-
node_4 -> node_11 [color=red, label="child of", arrowhead=diamond];
44-
node_8 -> node_12 [color=red, label="child of", arrowhead=diamond];
30+
node_5 [label="bevy_mod_scripting_core::handler::script_error_logger"];
31+
node_6 [label="script_integration_test_harness::dummy_before_post_update_system"];
32+
node_7 [label="script_integration_test_harness::dummy_post_update_system"];
33+
node_8 [label="on_test_post_update"];
34+
node_9 [label="custom_system_a"];
35+
node_10 [label="custom_system_b"];
36+
node_11 [label="SystemSet AssetEvents"];
37+
node_12 [label="SystemSet GarbageCollection"];
38+
node_13 [label="SystemSet ScriptSystem(custom_system_a)"];
39+
node_14 [label="SystemSet ScriptSystem(custom_system_b)"];
40+
node_0 -> node_11 [color=red, label="child of", arrowhead=diamond];
41+
node_1 -> node_11 [color=red, label="child of", arrowhead=diamond];
42+
node_2 -> node_11 [color=red, label="child of", arrowhead=diamond];
43+
node_3 -> node_11 [color=red, label="child of", arrowhead=diamond];
44+
node_4 -> node_12 [color=red, label="child of", arrowhead=diamond];
4545
node_9 -> node_13 [color=red, label="child of", arrowhead=diamond];
46-
node_5 -> node_6 [color=blue, label="runs before", arrowhead=normal];
47-
node_7 -> node_8 [color=blue, label="runs before", arrowhead=normal];
48-
node_7 -> node_9 [color=blue, label="runs before", arrowhead=normal];
46+
node_10 -> node_14 [color=red, label="child of", arrowhead=diamond];
47+
node_6 -> node_7 [color=blue, label="runs before", arrowhead=normal];
48+
node_8 -> node_9 [color=blue, label="runs before", arrowhead=normal];
49+
node_8 -> node_10 [color=blue, label="runs before", arrowhead=normal];
4950
}
5051
]]
5152
assert_str_eq(dot_graph, expected_dot_graph, "Expected the schedule graph to match the expected graph")

assets/tests/add_system/added_systems_run_in_parallel.rhai

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,26 @@ digraph {
2626
node_2 [label="bevy_asset::assets::Assets<()>::asset_events"];
2727
node_3 [label="bevy_asset::assets::Assets<bevy_mod_scripting_asset::script_asset::ScriptAsset>::asset_events"];
2828
node_4 [label="bevy_mod_scripting_bindings::allocator::garbage_collector"];
29-
node_5 [label="script_integration_test_harness::dummy_before_post_update_system"];
30-
node_6 [label="script_integration_test_harness::dummy_post_update_system"];
31-
node_7 [label="on_test_post_update"];
32-
node_8 [label="custom_system_a"];
33-
node_9 [label="custom_system_b"];
34-
node_10 [label="SystemSet AssetEvents"];
35-
node_11 [label="SystemSet GarbageCollection"];
36-
node_12 [label="SystemSet ScriptSystem(custom_system_a)"];
37-
node_13 [label="SystemSet ScriptSystem(custom_system_b)"];
38-
node_0 -> node_10 [color=red, label="child of", arrowhead=diamond];
39-
node_1 -> node_10 [color=red, label="child of", arrowhead=diamond];
40-
node_2 -> node_10 [color=red, label="child of", arrowhead=diamond];
41-
node_3 -> node_10 [color=red, label="child of", arrowhead=diamond];
42-
node_4 -> node_11 [color=red, label="child of", arrowhead=diamond];
43-
node_8 -> node_12 [color=red, label="child of", arrowhead=diamond];
29+
node_5 [label="bevy_mod_scripting_core::handler::script_error_logger"];
30+
node_6 [label="script_integration_test_harness::dummy_before_post_update_system"];
31+
node_7 [label="script_integration_test_harness::dummy_post_update_system"];
32+
node_8 [label="on_test_post_update"];
33+
node_9 [label="custom_system_a"];
34+
node_10 [label="custom_system_b"];
35+
node_11 [label="SystemSet AssetEvents"];
36+
node_12 [label="SystemSet GarbageCollection"];
37+
node_13 [label="SystemSet ScriptSystem(custom_system_a)"];
38+
node_14 [label="SystemSet ScriptSystem(custom_system_b)"];
39+
node_0 -> node_11 [color=red, label="child of", arrowhead=diamond];
40+
node_1 -> node_11 [color=red, label="child of", arrowhead=diamond];
41+
node_2 -> node_11 [color=red, label="child of", arrowhead=diamond];
42+
node_3 -> node_11 [color=red, label="child of", arrowhead=diamond];
43+
node_4 -> node_12 [color=red, label="child of", arrowhead=diamond];
4444
node_9 -> node_13 [color=red, label="child of", arrowhead=diamond];
45-
node_5 -> node_6 [color=blue, label="runs before", arrowhead=normal];
46-
node_7 -> node_8 [color=blue, label="runs before", arrowhead=normal];
47-
node_7 -> node_9 [color=blue, label="runs before", arrowhead=normal];
45+
node_10 -> node_14 [color=red, label="child of", arrowhead=diamond];
46+
node_6 -> node_7 [color=blue, label="runs before", arrowhead=normal];
47+
node_8 -> node_9 [color=blue, label="runs before", arrowhead=normal];
48+
node_8 -> node_10 [color=blue, label="runs before", arrowhead=normal];
4849
}`;
4950

5051
assert_str_eq.call(dot_graph, expected_dot_graph, "Expected the schedule graph to match the expected graph");

crates/bevy_mod_scripting_bindings/src/reference.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
//! we need wrapper types which have owned and ref variants.
77
use super::{WorldGuard, access_map::ReflectAccessId};
88
use crate::{
9-
ReflectAllocationId, ReflectAllocator, error::InteropError,
10-
reflection_extensions::PartialReflectExt, with_access_read, with_access_write,
9+
ReflectAllocationId, ReflectAllocator, ThreadWorldContainer, WorldContainer,
10+
error::InteropError, reflection_extensions::PartialReflectExt, with_access_read,
11+
with_access_write,
1112
};
1213
use bevy_ecs::{component::Component, ptr::Ptr, resource::Resource};
1314
use bevy_mod_scripting_derive::DebugWithTypeInfo;
@@ -64,7 +65,12 @@ impl DisplayWithTypeInfo for ReflectReference {
6465
// Safety: should be safe as the guard is invalidated when world is released per iteration
6566
let any: &dyn Any = unsafe { type_info_provider.as_any_static() };
6667

67-
if let Some(guard) = any.downcast_ref::<WorldGuard>() {
68+
let guard = any.downcast_ref::<WorldGuard>().cloned().or_else(|| {
69+
any.downcast_ref::<ThreadWorldContainer>()
70+
.and_then(|t| t.try_get_world().ok())
71+
});
72+
73+
if let Some(guard) = guard {
6874
if let Ok(r) = self.with_reflect(guard.clone(), |s| {
6975
PrintReflectAsDebug::new_with_opt_info(s, Some(type_info_provider))
7076
.to_string_with_type_info(f, Some(type_info_provider))
@@ -621,7 +627,12 @@ impl DisplayWithTypeInfo for ReflectBase {
621627
// Safety: should generally be safe, as the world guard is invalidated once the world is out of scope for the iteration
622628
let any: &dyn Any = unsafe { type_info_provider.as_any_static() };
623629

624-
if let Some(guard) = any.downcast_ref::<WorldGuard>() {
630+
let guard = any.downcast_ref::<WorldGuard>().cloned().or_else(|| {
631+
any.downcast_ref::<ThreadWorldContainer>()
632+
.and_then(|t| t.try_get_world().ok())
633+
});
634+
635+
if let Some(guard) = guard {
625636
let allocator = guard.allocator();
626637
let allocator = allocator.read();
627638
if let Some(allocation) = allocator.get(id) {

0 commit comments

Comments
 (0)