Skip to content

Preferences RemoveValue does not save #3229

Closed
@chriselkins

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions