Skip to content

Preferences don't all save when written in CloseIntercept #3170

Closed
@pztrn

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

When using fyne.App.Run() to start an application, only first written preference is saved in Preferences store.

How to reproduce

  1. Launch example code.
  2. Take a look at ${XDG_CONFIG_HOME}/fyne/some.test/preferences.json
  3. Be surprised that only width is saved.

Screenshots

No response

Example code

package main

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

var (
        a fyne.App
        wnd fyne.Window
)

func main() {
        a = app.NewWithID("some.test")
        wnd = a.NewWindow("Test")

        wnd.Resize(fyne.Size{
                Width: float32(a.Preferences().IntWithFallback("mainwindow/width", 800)),
                Height: float32(a.Preferences().IntWithFallback("mainwindow/height", 600)),
        })

        wnd.SetCloseIntercept(closeIntercept)

        wnd.Show()

        a.Run()
}

func closeIntercept() {
        windowSizes := wnd.Canvas().Size()

        a.Preferences().SetInt("mainwindow/width", int(windowSizes.Width))
        a.Preferences().SetInt("mainwindow/height", int(windowSizes.Height))

        wnd.Close()
}

Fyne version

2.2.3 and today's develop at b71c0f2

Go compiler version

1.18.4

Operating system

macOS

Operating system version

macOS 12.5

Additional Information

This problem does not appear when using fyne.Window.ShowAndRun.

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