Skip to content

Commit

Permalink
fix(core): 🐛 unit test error
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Adoo committed Sep 25, 2023
1 parent fa4b663 commit 1dec34e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 5 additions & 2 deletions core/src/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,12 @@ macro_rules! multi_parent_impl {
(p, child)
},
move |new_p, old_p, ctx| {
let arena = &ctx.tree.borrow().arena;
// Safety: we escape the borrow of arena, but we only access the children of the
// `old_p` and we know `compose_children` will not modifies the children of
// `old_p`.
let arena = unsafe { &(*ctx.tree.as_ptr()).arena };
let children = old_p.children(arena).map(|id| Widget::from_id(id, ctx));
new_p.compose_children(children, ctx).consume()
new_p.compose_children(children.into_iter(), ctx).consume()
},
)
} else {
Expand Down
10 changes: 5 additions & 5 deletions dev-helper/src/widget_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,24 @@ macro_rules! widget_test_suit {
/// use ribir_core::{ prelude::*, test_helper::* };
/// use ribir_dev_helper::*;
///
/// fn my_widget() -> Widget {
/// fn my_widget() -> impl WidgetBuilder {
/// fn_widget!{
/// @MockBox {
/// size: Size::new(100., 100.),
/// @MockBox {
/// size: Size::new(50., 50.)
/// }
/// }
/// }.into()
/// }
/// }
///
/// // only use to avoid conflict.
/// fn my_widget_a() -> Widget { my_widget() }
/// fn my_widget_a() -> impl WidgetBuilder { my_widget() }
///
/// // Only test the whole widget size.
/// widget_layout_test!(my_widget_a, width == 100., height == 100.,);
///
/// fn my_widget_b() -> Widget { my_widget() }
/// fn my_widget_b() -> impl WidgetBuilder { my_widget() }
/// // Only test the whole widget size but with a window size.
/// widget_layout_test!(
/// my_widget_b,
Expand All @@ -116,7 +116,7 @@ macro_rules! widget_test_suit {
/// height == 10.,
/// );
///
/// fn my_widget_c() -> Widget { my_widget() }
/// fn my_widget_c() -> impl WidgetBuilder { my_widget() }
/// // Test two widget layout information.
/// widget_layout_test!(
/// my_widget_c,
Expand Down
4 changes: 2 additions & 2 deletions widgets/src/lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ use ribir_core::prelude::*;
/// @Container {
/// size: Size::splat(40.),
/// background: Color::YELLOW,
/// }.into()
/// }.widget_build(ctx!())
/// )
/// }
/// }
Expand Down Expand Up @@ -96,7 +96,7 @@ use ribir_core::prelude::*;
/// @Container {
/// size: Size::splat(40.),
/// background: Color::YELLOW,
/// }.into()
/// }.widget_build(ctx!())
/// )
/// }
/// }
Expand Down

0 comments on commit 1dec34e

Please sign in to comment.