Skip to content

Commit

Permalink
Merge branch 'release/v2.4.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Apr 15, 2024
2 parents 6b2c99e + 32c0f15 commit d8e9fe0
Show file tree
Hide file tree
Showing 32 changed files with 311 additions and 121 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@
This file lists the main changes with each version of the Fyne toolkit.
More detailed release notes can be found on the [releases page](https://github.com/fyne-io/fyne/releases).

## 2.4.5 - 15 April 2024

### Fixed

* iOS files write would fail when over 16KB
* storage.Delete not supported on Android/iOS (#2120)
* layout.formLayout do not handle canvas.Text well in second column (#4665)
* Fix building with ios17.4 (#4741)
* Support template icon for system tray menu icons
* Fix recognition of missing XDG user directories (#4650)
* FileDialog.SetOnClosed not always working (#4651)
* Upgrade GLFW for performance improvements and bug fixes
* Multiple select popups can crash during background operations (#4730)
* Controlling a negative slider with the left arrow key blocks after 8 steps (#4736)
* cmd/fyne: command "get" is broken with Go 1.22 (#4684)
* Race condition during system tray menu refresh (#4697)
* Fyne release on Linux does not set Metadata().Release to true (#4711)
* RichText leaks memory when replacing segments (#4723)


## 2.4.4 - 13 February 2024

### Fixed
Expand Down
40 changes: 24 additions & 16 deletions cmd/fyne/internal/commands/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (

"github.com/urfave/cli/v2"
"golang.org/x/sys/execabs"

//lint:ignore SA1019 The recommended replacement does not solve the use-case
"golang.org/x/tools/go/vcs"
)

// Get returns the command which downloads and installs fyne applications.
Expand Down Expand Up @@ -57,20 +60,37 @@ func NewGetter() *Getter {

// Get automates the download and install of a named GUI app package.
func (g *Getter) Get(pkg string) error {
cmd := execabs.Command("go", "get", "-u", "-d", pkg)
cmd.Env = append(os.Environ(), "GO111MODULE=off") // cache the downloaded code
name := filepath.Base(pkg)
path, err := os.MkdirTemp("", fmt.Sprintf("fyne-get-%s-*", name))
if err != nil {
return err
}
defer os.RemoveAll(path)

repo, err := vcs.RepoRootForImportPath(pkg, false)
if err != nil {
return fmt.Errorf("failed to look up source control for package: %w", err)
}
if repo.VCS.Name != "Git" {
return errors.New("unsupported VCS: " + repo.VCS.Name)
}
cmd := execabs.Command("git", "clone", repo.Repo, "--depth=1", path)
cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr

err := cmd.Run()
err = cmd.Run()
if err != nil {
return err
}

path := filepath.Join(goPath(), "src", pkg)
if !util.Exists(path) { // the error above may be ignorable, unless the path was not found
return err
}

if repo.Root != pkg {
dir := strings.Replace(pkg, repo.Root, "", 1)
path = filepath.Join(path, dir)
}

install := &Installer{appData: g.appData, srcDir: path, release: true}
if err := install.validate(); err != nil {
return fmt.Errorf("failed to set up installer: %w", err)
Expand Down Expand Up @@ -121,15 +141,3 @@ func (g *Getter) Run(args []string) {
os.Exit(1)
}
}

func goPath() string {
cmd := execabs.Command("go", "env", "GOPATH")
out, err := cmd.CombinedOutput()

if err != nil {
home, _ := os.UserHomeDir()
return filepath.Join(home, "go")
}

return strings.TrimSpace(string(out[0 : len(out)-1]))
}
2 changes: 1 addition & 1 deletion cmd/fyne/internal/commands/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ func (p *Packager) validate() (err error) {
os.Chdir(p.srcDir)

p.appData.CustomMetadata = p.customMetadata.m
p.appData.Release = p.release

data, err := metadata.LoadStandard(p.srcDir)
if err == nil {
Expand All @@ -383,7 +384,6 @@ func (p *Packager) validate() (err error) {
data.Details.Icon = util.MakePathRelativeTo(p.srcDir, data.Details.Icon)
}

p.appData.Release = p.release
p.appData.mergeMetadata(data)
p.linuxAndBSDMetadata = data.LinuxAndBSD
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/fyne/internal/commands/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@ func (r *Releaser) PrintHelp(indent string) {
//
// Deprecated: A better version will be exposed in the future.
func (r *Releaser) Run(params []string) {
r.Packager.distribution = true
r.Packager.release = true

if err := r.validate(); err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
return
}

r.Packager.distribution = true
r.Packager.release = true

if err := r.beforePackage(); err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
return
Expand All @@ -207,13 +207,13 @@ func (r *Releaser) Run(params []string) {
}

func (r *Releaser) releaseAction(_ *cli.Context) error {
r.Packager.distribution = true
r.Packager.release = true

if err := r.validate(); err != nil {
return err
}

r.Packager.distribution = true
r.Packager.release = true

if err := r.beforePackage(); err != nil {
return err
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/fyne/internal/mobile/build_iosapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,11 +523,13 @@ var projPbxprojTmpl = template.Must(template.New("projPbxproj").Parse(`// !$*UTF
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
OS_ACTIVITY_MODE = "disabled";
MTL_ENABLE_DEBUG_INFO = {{if .Debug}}YES{{else}}NO{{end}};
PRODUCT_BUNDLE_IDENTIFIER = {{.BundleID}};
PROVISIONING_PROFILE_SPECIFIER = "{{.Profile}}";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
OS_ACTIVITY_MODE = "disable";
VALIDATE_PRODUCT = YES;
{{if not .BitcodeEnabled}}ENABLE_BITCODE = NO;{{end}}
};
Expand Down
6 changes: 3 additions & 3 deletions dialog/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,13 +703,13 @@ func (f *FileDialog) SetLocation(u fyne.ListableURI) {
// SetOnClosed sets a callback function that is called when
// the dialog is closed.
func (f *FileDialog) SetOnClosed(closed func()) {
if f.dialog == nil {
return
}
// If there is already a callback set, remember it and call both.
originalCallback := f.onClosedCallback

f.onClosedCallback = func(response bool) {
if f.dialog == nil {
return
}
closed()
if originalCallback != nil {
originalCallback(response)
Expand Down
10 changes: 10 additions & 0 deletions dialog/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,3 +630,13 @@ func TestCreateNewFolderInDir(t *testing.T) {
folderNameInputCreate := folderNameInputUi.Objects[3].(*fyne.Container).Objects[1].(*widget.Button)
assert.Equal(t, theme.ConfirmIcon(), folderNameInputCreate.Icon)
}

func TestSetOnClosedBeforeShow(t *testing.T) {
win := test.NewWindow(widget.NewLabel("Content"))
d := NewFileSave(func(fyne.URIWriteCloser, error) {}, win)
onClosedCalled := false
d.SetOnClosed(func() { onClosedCalled = true })
d.Show()
d.Hide()
assert.True(t, onClosedCalled)
}
6 changes: 5 additions & 1 deletion dialog/file_xdg.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package dialog
import (
"fmt"
"os"
"strings"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/storage"
Expand All @@ -32,7 +33,7 @@ func getFavoriteLocation(homeURI fyne.URI, name, fallbackName string) (fyne.URI,
loc = loc[:len(loc)-1]
locURI := storage.NewFileURI(string(loc))

if locURI.String() == homeURI.String() {
if strings.TrimRight(locURI.String(), "/") == strings.TrimRight(homeURI.String(), "/") {
fallback, _ := storage.Child(homeURI, fallbackName)
return fallback, fmt.Errorf("this computer does not define a %s folder", name)
}
Expand Down Expand Up @@ -63,6 +64,9 @@ func getFavoriteLocations() (map[string]fyne.ListableURI, error) {
for _, favName := range favoriteNames {
var uri fyne.URI
uri, err = getFavoriteLocation(homeURI, arguments[favName], favName)
if err != nil {
continue
}

listURI, err1 := storage.ListerForURI(uri)
if err1 != nil {
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ require (
github.com/fyne-io/glfw-js v0.0.0-20220120001248-ee7290d23504
github.com/fyne-io/image v0.0.0-20220602074514-4956b0afb3d2
github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240306074159-ea2d69986ecb
github.com/go-ole/go-ole v1.2.6
github.com/go-text/render v0.0.0-20230619120952-35bccb6164b8
github.com/go-text/render v0.1.0
github.com/go-text/typesetting v0.1.0
github.com/godbus/dbus/v5 v5.1.0
github.com/gopherjs/gopherjs v1.17.2
Expand All @@ -33,6 +33,7 @@ require (
golang.org/x/mod v0.12.0
golang.org/x/sys v0.13.0
golang.org/x/tools v0.12.0
golang.org/x/tools/go/vcs v0.1.0-deprecated
honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2
)

Expand Down
16 changes: 9 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,17 @@ github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20211213063430-748e38ca8aec/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b h1:GgabKamyOYguHqHjSkDACcgoPIz3w0Dis/zJ1wyHHHU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240306074159-ea2d69986ecb h1:S9I8pIVT5JHKDvmI1vQ0qs5fqxzUfhcZm/YbUC/8k1k=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240306074159-ea2d69986ecb/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-text/render v0.0.0-20230619120952-35bccb6164b8 h1:VkKnvzbvHqgEfm351rfr8Uclu5fnwq8HP2ximUzJsBM=
github.com/go-text/render v0.0.0-20230619120952-35bccb6164b8/go.mod h1:h29xCucjNsDcYb7+0rJokxVwYAq+9kQ19WiFuBKkYtc=
github.com/go-text/typesetting v0.0.0-20230616162802-9c17dd34aa4a/go.mod h1:evDBbvNR/KaVFZ2ZlDSOWWXIUKq0wCOEtzLxRM8SG3k=
github.com/go-text/render v0.1.0 h1:osrmVDZNHuP1RSu3pNG7Z77Sd2xSbcb/xWytAj9kyVs=
github.com/go-text/render v0.1.0/go.mod h1:jqEuNMenrmj6QRnkdpeaP0oKGFLDNhDkVKwGjsWWYU4=
github.com/go-text/typesetting v0.1.0 h1:vioSaLPYcHwPEPLT7gsjCGDCoYSbljxoHJzMnKwVvHw=
github.com/go-text/typesetting v0.1.0/go.mod h1:d22AnmeKq/on0HNv73UFriMKc4Ez6EqZAofLhAzpSzI=
github.com/go-text/typesetting-utils v0.0.0-20230616150549-2a7df14b6a22/go.mod h1:DDxDdQEnB70R8owOx3LVpEFvpMK9eeH1o2r0yZhFI9o=
github.com/go-text/typesetting-utils v0.0.0-20231211103740-d9332ae51f04 h1:zBx+p/W2aQYtNuyZNcTfinWvXBQwYtDfme051PR/lAY=
github.com/go-text/typesetting-utils v0.0.0-20231211103740-d9332ae51f04/go.mod h1:DDxDdQEnB70R8owOx3LVpEFvpMK9eeH1o2r0yZhFI9o=
github.com/go-text/typesetting-utils v0.0.0-20240329101916-eee87fb235a3 h1:levTnuLLUmpavLGbJYLJA7fQnKeS7P1eCdAlM+vReXk=
github.com/go-text/typesetting-utils v0.0.0-20240329101916-eee87fb235a3/go.mod h1:DDxDdQEnB70R8owOx3LVpEFvpMK9eeH1o2r0yZhFI9o=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
Expand Down Expand Up @@ -519,6 +518,7 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down Expand Up @@ -605,6 +605,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss=
golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM=
golang.org/x/tools/go/vcs v0.1.0-deprecated h1:cOIJqWBl99H1dH5LWizPa+0ImeeJq3t3cJjaeOWUAL4=
golang.org/x/tools/go/vcs v0.1.0-deprecated/go.mod h1:zUrvATBAvEI9535oC0yWYsLsHIV4Z7g63sNPVMtuBy8=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
1 change: 1 addition & 0 deletions internal/driver/glfw/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type gLDriver struct {

trayStart, trayStop func() // shut down the system tray, if used
systrayMenu *fyne.Menu // cache the menu set so we know when to refresh
systrayLock sync.Mutex
}

func toOSIcon(icon []byte) ([]byte, error) {
Expand Down
9 changes: 8 additions & 1 deletion internal/driver/glfw/driver_desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,20 @@ func itemForMenuItem(i *fyne.MenuItem, parent *systray.MenuItem) *systray.MenuIt
if err != nil {
fyne.LogError("Failed to convert systray icon", err)
} else {
item.SetIcon(img)
if _, ok := i.Icon.(*theme.ThemedResource); ok {
item.SetTemplateIcon(img, img)
} else {
item.SetIcon(img)
}
}
}
return item
}

func (d *gLDriver) refreshSystray(m *fyne.Menu) {
d.systrayLock.Lock()
defer d.systrayLock.Unlock()

d.systrayMenu = m
systray.ResetMenu()
d.refreshSystrayMenu(m, nil)
Expand Down
2 changes: 1 addition & 1 deletion internal/driver/glfw/loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (d *gLDriver) runGL() {
f.done <- struct{}{}
}
case <-eventTick.C:
d.tryPollEvents()
d.pollEvents()
windowsToRemove := 0
for _, win := range d.windowList() {
w := win.(*window)
Expand Down
10 changes: 1 addition & 9 deletions internal/driver/glfw/loop_desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
package glfw

import (
"fmt"

"fyne.io/fyne/v2"

"github.com/go-gl/glfw/v3.3/glfw"
Expand All @@ -24,13 +22,7 @@ func (d *gLDriver) initGLFW() {
})
}

func (d *gLDriver) tryPollEvents() {
defer func() {
if r := recover(); r != nil {
fyne.LogError(fmt.Sprint("GLFW poll event error: ", r), nil)
}
}()

func (d *gLDriver) pollEvents() {
glfw.PollEvents() // This call blocks while window is being resized, which prevents freeDirtyTextures from being called
}

Expand Down
14 changes: 3 additions & 11 deletions internal/driver/glfw/loop_goxjs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
package glfw

import (
"fmt"

"fyne.io/fyne/v2"

gl "github.com/fyne-io/gl-js"
glfw "github.com/fyne-io/glfw-js"
"github.com/fyne-io/gl-js"
"github.com/fyne-io/glfw-js"
)

func (d *gLDriver) initGLFW() {
Expand All @@ -24,13 +22,7 @@ func (d *gLDriver) initGLFW() {
})
}

func (d *gLDriver) tryPollEvents() {
defer func() {
if r := recover(); r != nil {
fyne.LogError(fmt.Sprint("GLFW poll event error: ", r), nil)
}
}()

func (d *gLDriver) pollEvents() {
glfw.PollEvents() // This call blocks while window is being resized, which prevents freeDirtyTextures from being called
}

Expand Down
4 changes: 0 additions & 4 deletions internal/driver/glfw/window_desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,10 +583,6 @@ func keyCodeToKeyName(code string) fyne.KeyName {
}

func keyToName(code glfw.Key, scancode int) fyne.KeyName {
if runtime.GOOS == "darwin" && scancode == 0x69 { // TODO remove once fixed upstream glfw/glfw#1786
code = glfw.KeyPrintScreen
}

ret := glfwKeyToKeyName(code)
if ret != fyne.KeyUnknown {
return ret
Expand Down
4 changes: 0 additions & 4 deletions internal/driver/glfw/window_goxjs.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,6 @@ func keyCodeToKeyName(code string) fyne.KeyName {
}

func keyToName(code glfw.Key, scancode int) fyne.KeyName {
if runtime.GOOS == "darwin" && scancode == 0x69 { // TODO remove once fixed upstream glfw/glfw#1786
code = glfw.KeyPrintScreen
}

ret := glfwKeyToKeyName(code)
if ret != fyne.KeyUnknown {
return ret
Expand Down
Loading

0 comments on commit d8e9fe0

Please sign in to comment.