Skip to content

Commit 850b53c

Browse files
committed
Exit app when last window is closed
1 parent 078a69d commit 850b53c

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

crates/gitbutler-tauri/src/main.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,11 @@ fn main() {
246246
.menu(menu::build)
247247
.on_window_event(|window, event| match event {
248248
#[cfg(target_os = "macos")]
249-
tauri::WindowEvent::CloseRequested { api, .. } => {
250-
if window.app_handle().windows().len() == 1 {
251-
tracing::debug!("Hiding all application windows and preventing exit");
252-
window.app_handle().hide().ok();
253-
api.prevent_close();
249+
tauri::WindowEvent::CloseRequested { .. } => {
250+
let app_handle = window.app_handle();
251+
if app_handle.windows().len() == 1 {
252+
app_handle.cleanup_before_exit();
253+
app_handle.exit(0);
254254
}
255255
}
256256
tauri::WindowEvent::Destroyed => {
@@ -276,18 +276,7 @@ fn main() {
276276
.build(tauri_context)
277277
.expect("Failed to build tauri app")
278278
.run(|app_handle, event| {
279-
#[cfg(target_os = "macos")]
280-
if let tauri::RunEvent::ExitRequested { api, .. } = event {
281-
tracing::debug!("Hiding all windows and preventing exit");
282-
app_handle.hide().ok();
283-
api.prevent_exit();
284-
}
285-
286-
// To make the compiler happy.
287-
#[cfg(not(target_os = "macos"))]
288-
{
289-
let _ = (app_handle, event);
290-
}
279+
let _ = (app_handle, event);
291280
});
292281
});
293282
}

0 commit comments

Comments
 (0)