Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition during system tray menu refresh #4697

Closed
2 tasks done
gabe565 opened this issue Mar 4, 2024 · 1 comment
Closed
2 tasks done

Race condition during system tray menu refresh #4697

gabe565 opened this issue Mar 4, 2024 · 1 comment
Labels
unverified A bug that has been reported but not verified

Comments

@gabe565
Copy link
Contributor

gabe565 commented Mar 4, 2024

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

Hello! I am porting a systray application to fyne, and I believe I have found a race condition. If an application refreshes the system tray menu from a Goroutine, menu items can be duplicated.

How to reproduce

  1. Create an application with a system tray menu.
  2. Add a lifecycle hook which refreshes the menu from a Goroutine (see example code)
  3. When run, menu items will be duplicated.

Screenshots

image

Example code

package main

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/driver/desktop"
)

func main() {
	a := app.New()

	if desk, ok := a.(desktop.App); ok {
		m := fyne.NewMenu("MyApp",
			fyne.NewMenuItem("Example", nil),
		)
		desk.SetSystemTrayMenu(m)
		a.Lifecycle().SetOnStarted(func() {
			go func() {
				m.Refresh()
			}()
		})
	}

	a.Run()
}

Fyne version

2.4.4

Go compiler version

1.22.0

Operating system and version

macOS Sonoma

Additional Information

No response

@gabe565 gabe565 added the unverified A bug that has been reported but not verified label Mar 4, 2024
@gabe565 gabe565 changed the title Race condition during systray refresh Race condition during system tray menu refresh Mar 4, 2024
@andydotxyz andydotxyz added this to the D fixes (v2.4.x) milestone Apr 4, 2024
@dweymouth
Copy link
Contributor

This got fixed but we forgot to close the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unverified A bug that has been reported but not verified
Projects
None yet
Development

No branches or pull requests

3 participants