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

Calling entry.SetPlaceHolder inside of OnChanged callback freezes app #4516

Closed
2 tasks done
dweymouth opened this issue Jan 6, 2024 · 2 comments
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@dweymouth
Copy link
Contributor

dweymouth commented Jan 6, 2024

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

Reported in Fyne discord.

Calling entry.SetPlaceHolder in the OnChanged callback when it's invoked from a select-all + backspace change (ie deleting all text) causes the app to freeze. It reportedly works in Fyne 2.3.5

How to reproduce

Run the example code. Type into the entry. Then Select all (Ctrl+A) and delete.

Screenshots

No response

Example code

package main

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

func main() {
    myApp := app.New()
    window := myApp.NewWindow("test")

    str := "hello"
    entry := widget.NewEntry()
    entry.SetText(str)
    entry.OnChanged = func(s string) {
        if entry.Text == "" {
            entry.SetPlaceHolder("bye")
        } else {
            str = s
        }
    }
    window.SetContent(entry)
    window.ShowAndRun()
}

Fyne version

2.4.3

Go compiler version

1.21.4

Operating system and version

Windows

Additional Information

No response

@dweymouth dweymouth added unverified A bug that has been reported but not verified bug Something isn't working and removed unverified A bug that has been reported but not verified labels Jan 6, 2024
@Jacalz
Copy link
Member

Jacalz commented Jan 6, 2024

I think this should be a quite simple fix. We just have to look at all the places we are calling OnChanged and make sure we aren't holding any locks when doing so. A quick glance shows this:

e.OnChanged(e.Text)

e.OnChanged(e.Text)

@Jacalz
Copy link
Member

Jacalz commented Jan 6, 2024

Fixed in upcoming v2.4.4 release

@Jacalz Jacalz closed this as completed Jan 6, 2024
andydotxyz pushed a commit that referenced this issue Feb 8, 2024
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

2 participants