Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions crates/tauri-runtime-wry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,10 +804,6 @@ impl std::fmt::Debug for WindowBuilderWrapper {
}
}

// SAFETY: this type is `Send` since `menu_items` are read only here
#[allow(clippy::non_send_fields_in_send_ty)]
unsafe impl Send for WindowBuilderWrapper {}

impl WindowBuilderBase for WindowBuilderWrapper {}
impl WindowBuilder for WindowBuilderWrapper {
fn new() -> Self {
Expand Down Expand Up @@ -5226,3 +5222,12 @@ fn to_tao_theme(theme: Option<Theme>) -> Option<TaoTheme> {
_ => None,
}
}

#[cfg(test)]
mod tests {
fn is_send<T: Send>() {}
#[test]
fn are_send() {
is_send::<super::WindowBuilderWrapper>();
}
}
10 changes: 5 additions & 5 deletions crates/tauri/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub(crate) type GlobalWebviewEventListener<R> =
Box<dyn Fn(&Webview<R>, &WebviewEvent) + Send + Sync>;
/// A closure that is run when the Tauri application is setting up.
pub type SetupHook<R> =
Box<dyn FnOnce(&mut App<R>) -> std::result::Result<(), Box<dyn std::error::Error>> + Send>;
Box<dyn FnOnce(&mut App<R>) -> Result<(), Box<dyn std::error::Error + Send + Sync>> + Send>;
/// A closure that is run every time a page starts or finishes loading.
pub type OnPageLoad<R> = dyn Fn(&Webview<R>, &PageLoadPayload<'_>) + Send + Sync + 'static;
pub type ChannelInterceptor<R> =
Expand Down Expand Up @@ -443,7 +443,7 @@ impl<R: Runtime> Clone for AppHandle<R> {

impl<'de, R: Runtime> CommandArg<'de, R> for AppHandle<R> {
/// Grabs the [`Window`] from the [`CommandItem`] and returns the associated [`AppHandle`]. This will never fail.
fn from_command(command: CommandItem<'de, R>) -> std::result::Result<Self, InvokeError> {
fn from_command(command: CommandItem<'de, R>) -> Result<Self, InvokeError> {
Ok(command.message.webview().app_handle)
}
}
Expand Down Expand Up @@ -1640,7 +1640,7 @@ tauri::Builder::default()
#[must_use]
pub fn setup<F>(mut self, setup: F) -> Self
where
F: FnOnce(&mut App<R>) -> std::result::Result<(), Box<dyn std::error::Error>> + Send + 'static,
F: FnOnce(&mut App<R>) -> Result<(), Box<dyn std::error::Error + Send + Sync>> + Send + 'static,
{
self.setup = Box::new(setup);
self
Expand Down Expand Up @@ -2353,15 +2353,15 @@ fn init_app_menu<R: Runtime>(menu: &Menu<R>) -> crate::Result<()> {
impl<R: Runtime> HasDisplayHandle for AppHandle<R> {
fn display_handle(
&self,
) -> std::result::Result<raw_window_handle::DisplayHandle<'_>, raw_window_handle::HandleError> {
) -> Result<raw_window_handle::DisplayHandle<'_>, raw_window_handle::HandleError> {
self.runtime_handle.display_handle()
}
}

impl<R: Runtime> HasDisplayHandle for App<R> {
fn display_handle(
&self,
) -> std::result::Result<raw_window_handle::DisplayHandle<'_>, raw_window_handle::HandleError> {
) -> Result<raw_window_handle::DisplayHandle<'_>, raw_window_handle::HandleError> {
self.handle.display_handle()
}
}
Expand Down
11 changes: 3 additions & 8 deletions crates/tauri/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@ use std::fmt;

/// A generic boxed error.
#[derive(Debug)]
pub struct SetupError(Box<dyn std::error::Error>);
pub struct SetupError(Box<dyn std::error::Error + Send + Sync>);

impl From<Box<dyn std::error::Error>> for SetupError {
fn from(error: Box<dyn std::error::Error>) -> Self {
impl From<Box<dyn std::error::Error + Send + Sync>> for SetupError {
fn from(error: Box<dyn std::error::Error + Send + Sync>) -> Self {
Self(error)
}
}

// safety: the setup error is only used on the main thread
// and we exit the process immediately.
unsafe impl Send for SetupError {}
unsafe impl Sync for SetupError {}

impl fmt::Display for SetupError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
Expand Down
Loading