diff --git a/flutter/lib/desktop/pages/connection_page.dart b/flutter/lib/desktop/pages/connection_page.dart index fc5b8e574..f73c6b0da 100644 --- a/flutter/lib/desktop/pages/connection_page.dart +++ b/flutter/lib/desktop/pages/connection_page.dart @@ -90,6 +90,9 @@ class _ConnectionPageState extends State Get.forceAppUpdate(); } isWindowMinisized = false; + } else if (eventName == 'close') { + // called more then one time + bind.mainOnMainWindowClose(); } } diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index 520efea70..b947fad47 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -619,7 +619,11 @@ pub fn main_set_peer_option_sync(id: String, key: String, value: String) -> Sync } pub fn main_set_peer_alias(id: String, alias: String) { - main_broadcast_message(&HashMap::from([("name", "alias"), ("id", &id), ("alias", &alias)])); + main_broadcast_message(&HashMap::from([ + ("name", "alias"), + ("id", &id), + ("alias", &alias), + ])); set_peer_option(id, "alias".to_owned(), alias) } @@ -1173,6 +1177,11 @@ pub fn main_account_auth_result() -> String { account_auth_result() } +pub fn main_on_main_window_close() { + #[cfg(windows)] + crate::portable_service::client::drop_portable_service_shared_memory(); +} + #[cfg(target_os = "android")] pub mod server_side { use jni::{ diff --git a/src/server/portable_service.rs b/src/server/portable_service.rs index 64d6c017b..861b04b3d 100644 --- a/src/server/portable_service.rs +++ b/src/server/portable_service.rs @@ -487,7 +487,7 @@ pub mod client { crate::portable_service::SHMEM_NAME, shmem_size, )?); - shutdown_hooks::add_shutdown_hook(drop_shmem); + shutdown_hooks::add_shutdown_hook(drop_portable_service_shared_memory); } let mut option = SHMEM.lock().unwrap(); let shmem = option.as_mut().unwrap(); @@ -507,7 +507,7 @@ pub mod client { Ok(()) } - extern "C" fn drop_shmem() { + pub extern "C" fn drop_portable_service_shared_memory() { log::info!("drop shared memory"); *SHMEM.lock().unwrap() = None; }