Skip to content

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

Closed
@dweymouth

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

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

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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions