Skip to content

Entry does not show the last (few) changes when updating a binding.String in a fast succession  #4082

Closed
@Roemer

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

As discussed in Slack (https://gophers.slack.com/archives/CB4QUBXGQ/p1689959990702439) there seems to be an issue when a binding.String is bound to an Entry and is quickly updated multiple times. In that case, the Entry does not get all the last changes until the binding is updated again.

How to reproduce

  1. Run the example code from below
  2. Have a look at the Window (and optionally the terminal output). Theoretically it should display a and b randomly counting from 0 to 19. But you will just see a nothing or a few entries. Then after 5 seconds, it will add a final string and suddenly renders all missing parts.

Screenshots

image

Example code

package main

import (
	"fmt"
	"strconv"
	"time"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/data/binding"
	"fyne.io/fyne/v2/widget"
)

func main() {
	a := app.New()
	w := a.NewWindow("Test")
	w.Resize(fyne.NewSize(700, 300))

	textBinding := binding.NewString()
	widget := widget.NewEntryWithData(textBinding)

	logChannel := make(chan string, 100)
	go func() {
		for text := range logChannel {
			fmt.Println(text)
			existingText, _ := textBinding.Get()
			fmt.Println(existingText)
			newText := existingText + "," + text
			textBinding.Set(newText)
		}
	}()

	go func() {
		time.Sleep(time.Second * 1)
		for i := 0; i < 20; i++ {
			text := "a" + strconv.Itoa(i)
			logChannel <- text
			time.Sleep(time.Millisecond * 1)
		}
	}()
	go func() {
		time.Sleep(time.Second * 1)
		for i := 0; i < 20; i++ {
			text := "b" + strconv.Itoa(i)
			logChannel <- text
			time.Sleep(time.Millisecond * 1)
		}
	}()

	go func() {
		time.Sleep(time.Second * 5)
		logChannel <- "final"
	}()

	w.SetContent(widget)
	w.CenterOnScreen()
	w.ShowAndRun()
}

Fyne version

v2.3.6-0.20230720061213-19e0c73660eb

Go compiler version

1.20.6

Operating system and version

Linux WSL2, Windows 10

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

    unverifiedA bug that has been reported but not verified

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions