Checkpoint
This commit is contained in:
@@ -102,10 +102,10 @@ impl<T> core::ops::DerefMut for Lease<T> {
|
||||
|
||||
impl<T> Drop for Lease<T> {
|
||||
fn drop(&mut self) {
|
||||
assert!(
|
||||
self.entity.is_none(),
|
||||
"Leases must be ended with EntityMap::end_lease"
|
||||
);
|
||||
if self.entity.is_some() {
|
||||
// We don't panic here, because other panics can cause us to drop the lease without ending it cleanly.
|
||||
log::error!("Leases must be ended with EntityMap::end_lease")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ pub fn view<S, E>(
|
||||
render: impl Fn(&mut S, &mut ViewContext<S>) -> E + Send + Sync + 'static,
|
||||
) -> View<S>
|
||||
where
|
||||
E: IntoAnyElement<S>,
|
||||
S: 'static + Send + Sync,
|
||||
E: Element<ViewState = S>,
|
||||
{
|
||||
View {
|
||||
state,
|
||||
@@ -86,6 +86,8 @@ impl<S: 'static + Send + Sync> Element for View<S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: Send + Sync + 'static> IdentifiedElement for View<S> {}
|
||||
|
||||
struct EraseViewState<ViewState: 'static + Send + Sync, ParentViewState> {
|
||||
view: View<ViewState>,
|
||||
parent_view_state_type: PhantomData<ParentViewState>,
|
||||
@@ -137,11 +139,9 @@ where
|
||||
trait ViewObject: 'static + Send + Sync {
|
||||
fn entity_id(&self) -> EntityId;
|
||||
fn layout(&mut self, cx: &mut WindowContext) -> (LayoutId, AnyBox);
|
||||
fn paint(&mut self, bounds: Bounds<Pixels>, element: &mut dyn Any, cx: &mut WindowContext);
|
||||
fn paint(&mut self, bounds: Bounds<Pixels>, element: &mut AnyBox, cx: &mut WindowContext);
|
||||
}
|
||||
|
||||
impl<S: Send + Sync + 'static> IdentifiedElement for View<S> {}
|
||||
|
||||
impl<S: Send + Sync + 'static> ViewObject for View<S> {
|
||||
fn entity_id(&self) -> EntityId {
|
||||
self.state.id
|
||||
@@ -158,7 +158,7 @@ impl<S: Send + Sync + 'static> ViewObject for View<S> {
|
||||
})
|
||||
}
|
||||
|
||||
fn paint(&mut self, _: Bounds<Pixels>, element: &mut dyn Any, cx: &mut WindowContext) {
|
||||
fn paint(&mut self, _: Bounds<Pixels>, element: &mut AnyBox, cx: &mut WindowContext) {
|
||||
cx.with_element_id(IdentifiedElement::element_id(self), |cx| {
|
||||
self.state.update(cx, |state, cx| {
|
||||
let element = element.downcast_mut::<AnyElement<S>>().unwrap();
|
||||
@@ -208,7 +208,7 @@ impl Element for AnyView {
|
||||
element: &mut AnyBox,
|
||||
cx: &mut ViewContext<Self::ViewState>,
|
||||
) {
|
||||
self.view.lock().paint(bounds, element.as_mut(), cx)
|
||||
self.view.lock().paint(bounds, element, cx)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user