Skip to content

Commit dbe0d21

Browse files
committed
fix(core): initialize system tray before app windows
1 parent 4042769 commit dbe0d21

2 files changed

Lines changed: 28 additions & 23 deletions

File tree

.changes/fix-tray-command.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch
3+
---
4+
5+
Initialize system tray before windows so `tray_handle` can be accessed on command handlers.

core/tauri/src/app.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -914,29 +914,6 @@ impl<R: Runtime> Builder<R> {
914914
},
915915
};
916916

917-
app.manager.initialize_plugins(&app.handle())?;
918-
919-
let pending_labels = self
920-
.pending_windows
921-
.iter()
922-
.map(|p| p.label.clone())
923-
.collect::<Vec<_>>();
924-
925-
#[cfg(feature = "updater")]
926-
let mut main_window = None;
927-
928-
for pending in self.pending_windows {
929-
let pending = app
930-
.manager
931-
.prepare_window(app.handle.clone(), pending, &pending_labels)?;
932-
let detached = app.runtime.as_ref().unwrap().create_window(pending)?;
933-
let _window = app.manager.attach_window(app.handle(), detached);
934-
#[cfg(feature = "updater")]
935-
if main_window.is_none() {
936-
main_window = Some(_window);
937-
}
938-
}
939-
940917
#[cfg(feature = "system-tray")]
941918
if let Some(system_tray) = self.system_tray {
942919
let mut ids = HashMap::new();
@@ -1027,6 +1004,29 @@ impl<R: Runtime> Builder<R> {
10271004
}
10281005
}
10291006

1007+
app.manager.initialize_plugins(&app.handle())?;
1008+
1009+
let pending_labels = self
1010+
.pending_windows
1011+
.iter()
1012+
.map(|p| p.label.clone())
1013+
.collect::<Vec<_>>();
1014+
1015+
#[cfg(feature = "updater")]
1016+
let mut main_window = None;
1017+
1018+
for pending in self.pending_windows {
1019+
let pending = app
1020+
.manager
1021+
.prepare_window(app.handle.clone(), pending, &pending_labels)?;
1022+
let detached = app.runtime.as_ref().unwrap().create_window(pending)?;
1023+
let _window = app.manager.attach_window(app.handle(), detached);
1024+
#[cfg(feature = "updater")]
1025+
if main_window.is_none() {
1026+
main_window = Some(_window);
1027+
}
1028+
}
1029+
10301030
(self.setup)(&mut app).map_err(|e| crate::Error::Setup(e))?;
10311031

10321032
#[cfg(feature = "updater")]

0 commit comments

Comments
 (0)