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

binding.String===>Quick refresh *b.val will appear with new data reset by a call to OnChange #3774

Closed
2 tasks done
MrWen opened this issue Mar 30, 2023 · 2 comments
Closed
2 tasks done
Labels
unverified A bug that has been reported but not verified

Comments

@MrWen
Copy link

MrWen commented Mar 30, 2023

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

// updateText updates the internal text to the given value
func (e *Entry) updateText(text string) {
	var callback func(string)
	e.setFieldsAndRefresh(func() {
		changed := e.Text != text
		e.Text = text
		e.syncSegments()
		e.text.updateRowBounds()

		if e.Text != "" {
			e.dirty = true
		}

		if changed {
			callback = e.OnChanged
		}
	})

	e.Validate()

	if callback != nil {
		callback(text)
	}
}

func (e *Entry) writeData(data binding.DataItem) {
	if data == nil {
		return
	}
	textTarget, ok := data.(binding.String)
	if !ok {
		return
	}
	curValue, err := textTarget.Get()
	if err == nil && curValue == e.Text {
		e.conversionError = nil
		return
	}
	e.conversionError = textTarget.Set(e.Text)
}

How to reproduce

Because refreshing Entry and Set are asynchronous operations。

Quick call String.Set。 Old data overwrites new data when writeData is executed。

Screenshots

No response

Example code

binding := binding.NewString()
entry := widget.NewMultiLineEntry()
entry.Bind(binding)

go func() {
var num int
 for {
str :=fmt.Sprintf("%d", num)
binding.Set(str)
}
}

Fyne version

2.3.2

Go compiler version

1.20

Operating system and version

Window11

Additional Information

No response

@MrWen MrWen added the unverified A bug that has been reported but not verified label Mar 30, 2023
@AlexNigl
Copy link

Probably the same root cause as #3887

@andydotxyz andydotxyz mentioned this issue Jul 14, 2023
3 tasks
@andydotxyz
Copy link
Member

Fixed on develop and release/v2.3.x branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unverified A bug that has been reported but not verified
Projects
None yet
Development

No branches or pull requests

3 participants