All tests passing.
This commit is contained in:
parent
9e701c41ae
commit
0fa96e2075
|
@ -1,9 +1,9 @@
|
||||||
error: auto impl delegates call to `update`, but this manual impl does not
|
error: auto impl delegates call to `update`, but this manual impl does not
|
||||||
`#[deny_(zero_ui::missing_delegate)]` is on
|
`#[deny_(zero_ui::missing_delegate)]` is on
|
||||||
--> cases/ui_node/missing_matching_delegate_child.rs:18:55
|
--> cases/ui_node/missing_matching_delegate_child.rs:18:51
|
||||||
|
|
|
|
||||||
18 | fn update(&mut self, updates: &WidgetUpdates) {
|
18 | fn update(&mut self, updates: &WidgetUpdates) {
|
||||||
| _______________________________________________________^
|
| ___________________________________________________^
|
||||||
19 | | let _ = updates;
|
19 | | let _ = updates;
|
||||||
20 | | // does not call self.child.update(updates);
|
20 | | // does not call self.child.update(updates);
|
||||||
21 | | }
|
21 | | }
|
||||||
|
|
|
@ -4,7 +4,7 @@ error: expected square brackets
|
||||||
10 | #![allow(inner_attribute)]
|
10 | #![allow(inner_attribute)]
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: expected path
|
error: expected identifier
|
||||||
--> cases/widget/malformed_property_attribute.rs:11:11
|
--> cases/widget/malformed_property_attribute.rs:11:11
|
||||||
|
|
|
|
||||||
11 | #[!foo]
|
11 | #[!foo]
|
||||||
|
|
|
@ -18,6 +18,7 @@ use std::{mem, thread};
|
||||||
use crate::app::HeadlessApp;
|
use crate::app::HeadlessApp;
|
||||||
use crate::context::{UPDATES, WIDGET};
|
use crate::context::{UPDATES, WIDGET};
|
||||||
use crate::crate_util::{Handle, WeakHandle};
|
use crate::crate_util::{Handle, WeakHandle};
|
||||||
|
use crate::task;
|
||||||
use crate::task::ui::UiTask;
|
use crate::task::ui::UiTask;
|
||||||
|
|
||||||
/// Represents a handler in a widget context.
|
/// Represents a handler in a widget context.
|
||||||
|
@ -1708,7 +1709,6 @@ impl HeadlessApp {
|
||||||
|
|
||||||
if !pending.is_empty() {
|
if !pending.is_empty() {
|
||||||
let start_time = Instant::now();
|
let start_time = Instant::now();
|
||||||
#[allow(clippy::blocks_in_if_conditions)] // false positive, see https://github.com/rust-lang/rust-clippy/issues/7580
|
|
||||||
while {
|
while {
|
||||||
pending.retain(|h| h());
|
pending.retain(|h| h());
|
||||||
!pending.is_empty()
|
!pending.is_empty()
|
||||||
|
@ -1738,26 +1738,38 @@ impl HeadlessApp {
|
||||||
|
|
||||||
/// Polls a `future` and updates the app repeatedly until it completes or the `timeout` is reached.
|
/// Polls a `future` and updates the app repeatedly until it completes or the `timeout` is reached.
|
||||||
pub fn block_on_fut<F: Future>(&mut self, future: F, timeout: Duration) -> Result<F::Output, String> {
|
pub fn block_on_fut<F: Future>(&mut self, future: F, timeout: Duration) -> Result<F::Output, String> {
|
||||||
|
let future = task::with_deadline(future, timeout);
|
||||||
|
let mut future = std::pin::pin!(future);
|
||||||
|
|
||||||
let waker = UPDATES.waker(vec![]);
|
let waker = UPDATES.waker(vec![]);
|
||||||
let mut cx = std::task::Context::from_waker(&waker);
|
let mut cx = std::task::Context::from_waker(&waker);
|
||||||
let start_time = Instant::now();
|
|
||||||
let mut future = std::pin::pin!(future);
|
|
||||||
loop {
|
loop {
|
||||||
if start_time.elapsed() >= timeout {
|
let mut fut_poll = future.as_mut().poll(&mut cx);
|
||||||
return Err(format!("reached timeout `{timeout:?}`"));
|
let flow = self.update_observe(
|
||||||
|
|| {
|
||||||
|
if fut_poll.is_pending() {
|
||||||
|
fut_poll = future.as_mut().poll(&mut cx);
|
||||||
}
|
}
|
||||||
match future.as_mut().poll(&mut cx) {
|
},
|
||||||
std::task::Poll::Ready(r) => {
|
true,
|
||||||
return Ok(r);
|
);
|
||||||
|
|
||||||
|
match fut_poll {
|
||||||
|
std::task::Poll::Ready(r) => match r {
|
||||||
|
Ok(r) => return Ok(r),
|
||||||
|
Err(e) => return Err(e.to_string()),
|
||||||
|
},
|
||||||
|
std::task::Poll::Pending => {}
|
||||||
}
|
}
|
||||||
std::task::Poll::Pending => match self.update(false) {
|
|
||||||
|
match flow {
|
||||||
crate::app::ControlFlow::Poll => continue,
|
crate::app::ControlFlow::Poll => continue,
|
||||||
crate::app::ControlFlow::Wait => {
|
crate::app::ControlFlow::Wait => {
|
||||||
thread::yield_now();
|
thread::yield_now();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
crate::app::ControlFlow::Exit => return Err("app exited".to_owned()),
|
crate::app::ControlFlow::Exit => return Err("app exited".to_owned()),
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -595,11 +595,15 @@ where
|
||||||
R: VarValue + Send + 'static,
|
R: VarValue + Send + 'static,
|
||||||
F: Future<Output = R> + Send + 'static,
|
F: Future<Output = R> + Send + 'static,
|
||||||
{
|
{
|
||||||
|
// !!: replace with var directly
|
||||||
let (sender, response) = response_channel();
|
let (sender, response) = response_channel();
|
||||||
|
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
let r = task.await;
|
let r = task.await;
|
||||||
let _ = sender.send_response(r);
|
match sender.send_response(r) {
|
||||||
|
Ok(()) => {}
|
||||||
|
Err(e) => tracing::error!("failed to respond, {e}"),
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
response
|
response
|
||||||
|
|
Loading…
Reference in New Issue