@@ -10,10 +10,14 @@ import (
1010 "fyne.io/fyne/v2/internal/build"
1111)
1212
13- // mainGoroutineID stores the main goroutine ID.
14- // This ID must be initialized during setup by calling `SetMainGoroutine` because
15- // a main goroutine may not equal to 1 due to the influence of a garbage collector.
16- var mainGoroutineID atomic.Uint64
13+ var (
14+ // mainGoroutineID stores the main goroutine ID.
15+ // This ID must be initialized during setup by calling `SetMainGoroutine` because
16+ // a main goroutine may not equal to 1 due to the influence of a garbage collector.
17+ mainGoroutineID atomic.Uint64
18+
19+ warnedNotMigrated bool
20+ )
1721
1822func SetMainGoroutine () {
1923 mainGoroutineID .Store (goroutineID ())
@@ -29,6 +33,7 @@ func EnsureNotMain(fn func()) {
2933 fn ()
3034 return
3135 }
36+ PrintFyneDoWarning ()
3237
3338 log .Println ("*** Error in Fyne call thread, fyne.Do[AndWait] called from main goroutine ***" )
3439 log .Println ("*** This error needs to be addressed as it will become a deadlock soon ***" )
@@ -48,6 +53,7 @@ func EnsureMain(fn func()) {
4853 fn ()
4954 return
5055 }
56+ PrintFyneDoWarning ()
5157
5258 log .Println ("*** Error in Fyne call thread, this should have been called in fyne.Do[AndWait] ***" )
5359 log .Println ("*** This error needs to be addressed as it could cause concurrent errors soon ***" )
@@ -89,3 +95,14 @@ func goroutineID() (id uint64) {
8995
9096 return id
9197}
98+
99+ func PrintFyneDoWarning () {
100+ if warnedNotMigrated { // shown before
101+ return
102+ }
103+
104+ warnedNotMigrated = true
105+ log .Println ("*** This application has not been migrated to the fyne.Do threading model ***" )
106+ log .Println ("*** The next major Fyne release will remove this safety! ***" )
107+ log .Println ("*** Read more at https://docs.fyne.io/started/goroutines ***" )
108+ }
0 commit comments