mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
fix(core): dialog freezing regression on macOS (#1768)
This commit is contained in:
committed by
GitHub
parent
72b8048b5a
commit
d06e1de46b
@@ -104,6 +104,13 @@ impl Module {
|
||||
.and_then(|r| r.json)
|
||||
.map_err(InvokeError::from)
|
||||
}),
|
||||
// on macOS, the dialog must run on another thread: https://github.com/rust-windowing/winit/issues/1779
|
||||
// we do the same on Windows just to stay consistent with `tao` (and it also improves UX because of the event loop)
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
Self::Dialog(cmd) => resolver
|
||||
.respond_async(async move { cmd.run().and_then(|r| r.json).map_err(InvokeError::from) }),
|
||||
// on Linux, the dialog must run on the main thread.
|
||||
#[cfg(target_os = "linux")]
|
||||
Self::Dialog(cmd) => {
|
||||
let _ = window.run_on_main_thread(|| {
|
||||
resolver
|
||||
|
||||
@@ -50,7 +50,7 @@ use crate::{
|
||||
runtime::window::PendingWindow,
|
||||
};
|
||||
use serde::Serialize;
|
||||
use std::{borrow::Borrow, collections::HashMap, path::PathBuf, sync::Arc};
|
||||
use std::{borrow::Borrow, collections::HashMap, sync::Arc};
|
||||
|
||||
// Export types likely to be used by the application.
|
||||
#[cfg(any(feature = "menu", feature = "system-tray"))]
|
||||
@@ -137,7 +137,7 @@ pub struct Context<A: Assets> {
|
||||
|
||||
/// The icon to use use on the system tray UI.
|
||||
#[cfg(target_os = "linux")]
|
||||
pub system_tray_icon: Option<PathBuf>,
|
||||
pub system_tray_icon: Option<std::path::PathBuf>,
|
||||
|
||||
/// The icon to use use on the system tray UI.
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
|
||||
@@ -180,6 +180,7 @@ impl<P: Params> Window<P> {
|
||||
self.window.dispatcher.clone()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn run_on_main_thread<F: FnOnce() + Send + 'static>(&self, f: F) -> crate::Result<()> {
|
||||
self
|
||||
.window
|
||||
|
||||
Reference in New Issue
Block a user