mirror of
https://github.com/safing/portmaster
synced 2025-09-05 12:09:14 +00:00
[desktop] Fix tauri unexpected exits
This commit is contained in:
parent
4ed4640fee
commit
e162c81978
2 changed files with 18 additions and 2 deletions
|
@ -22,7 +22,7 @@ use log::{debug, error, info, LevelFilter};
|
||||||
use portmaster::PortmasterExt;
|
use portmaster::PortmasterExt;
|
||||||
use tauri_plugin_log::RotationStrategy;
|
use tauri_plugin_log::RotationStrategy;
|
||||||
use traymenu::setup_tray_menu;
|
use traymenu::setup_tray_menu;
|
||||||
use window::{close_splash_window, create_main_window};
|
use window::{close_splash_window, create_main_window, hide_splash_window};
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
@ -77,7 +77,11 @@ impl portmaster::Handler for WsHandler {
|
||||||
// so we don't show the splash-screen when we loose connection.
|
// so we don't show the splash-screen when we loose connection.
|
||||||
self.is_first_connect = false;
|
self.is_first_connect = false;
|
||||||
|
|
||||||
if let Err(err) = close_splash_window(&self.handle) {
|
// The order is important. If all current windows are destroyed tauri will exit.
|
||||||
|
// First create the main ui window then destroy the splash screen.
|
||||||
|
|
||||||
|
// Hide splash screen. Will be closed after main window is created.
|
||||||
|
if let Err(err) = hide_splash_window(&self.handle) {
|
||||||
error!("failed to close splash window: {}", err.to_string());
|
error!("failed to close splash window: {}", err.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +94,11 @@ impl portmaster::Handler for WsHandler {
|
||||||
debug!("created main window")
|
debug!("created main window")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now it is safe to destroy the splash window.
|
||||||
|
if let Err(err) = close_splash_window(&self.handle) {
|
||||||
|
error!("failed to close splash window: {}", err.to_string());
|
||||||
|
}
|
||||||
|
|
||||||
let handle = self.handle.clone();
|
let handle = self.handle.clone();
|
||||||
tauri::async_runtime::spawn(async move {
|
tauri::async_runtime::spawn(async move {
|
||||||
traymenu::tray_handler(cli, handle).await;
|
traymenu::tray_handler(cli, handle).await;
|
||||||
|
|
|
@ -98,6 +98,13 @@ pub fn close_splash_window(app: &AppHandle) -> Result<()> {
|
||||||
return Err(tauri::Error::WindowNotFound);
|
return Err(tauri::Error::WindowNotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn hide_splash_window(app: &AppHandle) -> Result<()> {
|
||||||
|
if let Some(window) = app.get_webview_window("splash") {
|
||||||
|
return window.hide();
|
||||||
|
}
|
||||||
|
return Err(tauri::Error::WindowNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
/// Opens a window for the tauri application.
|
/// Opens a window for the tauri application.
|
||||||
///
|
///
|
||||||
/// If the main window has already been created, it is instructed to
|
/// If the main window has already been created, it is instructed to
|
||||||
|
|
Loading…
Add table
Reference in a new issue