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 {