mirror of
https://github.com/StuffAnThings/qbit_manage.git
synced 2025-10-07 20:40:28 +08:00
refactor(desktop): improve mutex error handling in open_app_window
Replace unwrap_or_else with explicit match for cleaner error handling when accessing MINIMIZE_TO_TRAY mutex. This provides better readability and follows Rust best practices for error handling.
This commit is contained in:
parent
d24d2e0954
commit
f39b7e998b
2 changed files with 8 additions and 5 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
4.6.3-develop12
|
||||
4.6.3-develop13
|
||||
|
|
|
@ -401,10 +401,13 @@ async fn wait_until_ready(port: u16, base_url: &Option<String>, timeout: Duratio
|
|||
|
||||
fn open_app_window(app: &AppHandle) {
|
||||
// Check if minimize to tray is enabled and respect it
|
||||
let minimize_to_tray = *MINIMIZE_TO_TRAY.lock().unwrap_or_else(|_| {
|
||||
// If lock fails, load setting directly
|
||||
std::sync::Mutex::new(load_minimize_setting(app))
|
||||
});
|
||||
let minimize_to_tray = match MINIMIZE_TO_TRAY.lock() {
|
||||
Ok(guard) => *guard,
|
||||
Err(_) => {
|
||||
// If lock fails, load setting directly
|
||||
load_minimize_setting(app)
|
||||
}
|
||||
};
|
||||
|
||||
// Only show window if minimize to tray is disabled, or if explicitly requested
|
||||
if !minimize_to_tray {
|
||||
|
|
Loading…
Add table
Reference in a new issue