Store the UI thread ID earlier

This commit is contained in:
Stefan Haller 2026-07-15 15:19:55 +02:00
parent 87ef96974e
commit c23bcd6d94

View file

@ -293,6 +293,12 @@ func NewGui(opts NewGuiOpts) (*Gui, error) {
g.playRecording = opts.PlayRecording
// Record the UI thread here, at construction. This assumes NewGui is called
// on the same goroutine that will run MainLoop, which holds for all our
// callers -- and it means IsUIThread is already correct for the UI work that
// runs during startup, before we reach MainLoop.
g.uiThreadID.Store(goid.Get())
return g, nil
}
@ -977,8 +983,6 @@ func (g *Gui) SetManagerFunc(manager func(*Gui) error) {
func (g *Gui) MainLoop() error {
defer close(g.loopExited)
g.uiThreadID.Store(goid.Get())
go func() {
for {
select {