You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When fyne_settings is executed and a setting is changed, the change is written to the settings.json file, which triggers a WRITE event twice via fsnotify. Under certain conditions that will trigger a Fyne error: Settings load error.
To Reproduce:
Steps to reproduce the behaviour:
cd \fyne\cmd\fyne_settings
go install . && fyne_settings
Change a setting and click Apply
The error will appear in the output window
Screenshots:
n/a
Example code:
Seen in Fyne v1.3.0
Device (please complete the following information):
OS: Windows 10 Pro x64
Version: Build 2004
Go version: 1.14.4 x64
Fyne version: v1.3.0
The text was updated successfully, but these errors were encountered:
The reason this is happening (again, at least on Windows (NTFS to be even more exact), as the filesystem semantics may be different on other systems) appears to be related to how watchFile()'s callback works and what's actually happening in saveToFile().
In saveToFile() (triggered by pressing Apply), Create() is called, which truncates the file if it exists. This causes a filesystem write, which will eventually be detected by fsnotify's watcher, triggering the callback above.
Then, Encode() writes the updated information to the file, again triggering the same callback.
The result is that fileChanged() (with its load() call) gets called twice in quick succession during each save. It appears one of the load() calls is being made while the save() write is still in progress.
If you add something that takes a bit of time in fileChanged() before s.load(), the problem goes away. A brief sleep (time.Sleep(100 * time.Millisecond)) or even a Println() is enough to ensure the watcher doesn't load the file before the parameter save is complete. This is not a best practice of course - it would be better to do something more deterministic (perhaps via a semaphore) to ensure a save() is not in progress during load(), at least within the same application.
Describe the bug:
This may or may not be Windows-specific.
When
fyne_settings
is executed and a setting is changed, the change is written to thesettings.json
file, which triggers a WRITE event twice via fsnotify. Under certain conditions that will trigger aFyne error: Settings load error
.To Reproduce:
Steps to reproduce the behaviour:
cd \fyne\cmd\fyne_settings
go install . && fyne_settings
Apply
Screenshots:
n/a
Example code:
Seen in Fyne v1.3.0
Device (please complete the following information):
The text was updated successfully, but these errors were encountered: