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

Preferences RemoveValue does not save #3229

Closed
2 tasks done
chriselkins opened this issue Aug 29, 2022 · 2 comments
Closed
2 tasks done

Preferences RemoveValue does not save #3229

chriselkins opened this issue Aug 29, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@chriselkins
Copy link

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

I have tested setting and removing values on Windows and Linux. I am able to set and write values to the preferences file but RemoveValue does not work. I'm using Fyne v2.2.3.

I can confirm on Linux that the code below creates a preferences file (~/.config/fyne/com.vitalitysouth.test/preferences.json) and that file contains the contents: {"num":42}

Even if I comment out or remove the Set() line, RemoveValue still will not remove the value from the preferences.json file.

package main

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

func main() {
	a := app.NewWithID("com.vitalitysouth.test")
	w := a.NewWindow("Test")

	a.Preferences().SetInt("num", 42)

	a.Preferences().RemoveValue("num")

	w.ShowAndRun()
}

Relevant go.mod:

        fyne.io/fyne/v2 v2.2.3
        fyne.io/systray v1.10.1-0.20220621085403-9a2652634e93 // indirect
        github.com/fyne-io/gl-js v0.0.0-20220802150000-8e339395f381 // indirect
        github.com/fyne-io/glfw-js v0.0.0-20220517201726-bebc2019cd33 // indirect
        github.com/fyne-io/image v0.0.0-20220602074514-4956b0afb3d2 // indirect

How to reproduce

  1. Create a bare bones fyne app.
  2. Set a preference.
  3. Try to use RemoveValue to remove the preference.

Screenshots

No response

Example code

package main

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

func main() {
	a := app.NewWithID("com.vitalitysouth.test")
	w := a.NewWindow("Test")

	a.Preferences().SetInt("num", 42)

	a.Preferences().RemoveValue("num")

	w.ShowAndRun()
}

Fyne version

2.2.3

Go compiler version

1.19

Operating system

Linux

Operating system version

WSL Ubuntu 20.04

Additional Information

No response

@chriselkins chriselkins added the unverified A bug that has been reported but not verified label Aug 29, 2022
@chriselkins
Copy link
Author

I noticed that if I make a Set() call after the RemoveValue() call, then the RemoveValue() call will take effect. So, as a workaround, the following code allows RemoveValue() to work.

package main

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

func main() {
	a := app.NewWithID("com.vitalitysouth.test")
	w := a.NewWindow("Test")

	a.Preferences().SetInt("num", 42)

	a.Preferences().RemoveValue("num")

	a.Preferences().SetInt("tmp", 43)

	w.ShowAndRun()
}

@andydotxyz andydotxyz changed the title Preferences RemoveValue does not work Preferences RemoveValue does not save Aug 29, 2022
andydotxyz added a commit to andydotxyz/fyne that referenced this issue Aug 29, 2022
@andydotxyz
Copy link
Member

On develop branch for next release

@Jacalz Jacalz added bug Something isn't working and removed unverified A bug that has been reported but not verified labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants