From 9174be76f293fb0f88298c7363ec2ff689fa8a7c Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Tue, 23 Dec 2025 06:33:09 +1100 Subject: [PATCH] Prevent app crashing when calling systray.Run() before app.Run() (#4826) --- v3/UNRELEASED_CHANGELOG.md | 1 + v3/pkg/application/systemtray.go | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/v3/UNRELEASED_CHANGELOG.md b/v3/UNRELEASED_CHANGELOG.md index 8e4648038..98c0451dd 100644 --- a/v3/UNRELEASED_CHANGELOG.md +++ b/v3/UNRELEASED_CHANGELOG.md @@ -23,6 +23,7 @@ After processing, the content will be moved to the main changelog and this file ## Fixed +- Prevent app crashing when calling systray.Run() before app.Run() by @leaanthony ## Deprecated diff --git a/v3/pkg/application/systemtray.go b/v3/pkg/application/systemtray.go index ef0525e54..0735b52e2 100644 --- a/v3/pkg/application/systemtray.go +++ b/v3/pkg/application/systemtray.go @@ -96,6 +96,13 @@ func (s *SystemTray) Label() string { } func (s *SystemTray) Run() { + + // exit early if application isn't running. + // app.Run() will call this + if globalApplication == nil || globalApplication.running == false { + return + } + s.impl = newSystemTrayImpl(s) if s.attachedWindow.Window != nil {