-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Data binding with widget.List sometimes crash while scrolling #2125
Comments
Are you able to see where the |
I will try to investigate |
After some tests, the l.textListener = binding.NewDataListener(func() {
fmt.Printf("label: %p, data: %p\n", l, l.textSource)
...
}) And I got this:
My thought is that this occurs because there are on-going callbacks processing (that depends on textSource) when |
This code reproduce the problem very quickly: package main
import (
"fmt"
"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(300, 300))
bindstr := binding.NewString()
label := widget.NewLabel("")
label.Bind(bindstr)
go func() {
i := 0
for {
bindstr.Set(fmt.Sprintf("Counter: %d", i))
i++
}
}()
go func() {
time.Sleep(1 * time.Second)
label.Unbind()
}()
w.SetContent(label)
w.ShowAndRun()
} |
Maybe type DataListener interface {
DataChanged()
Destroy()
}
type listener struct {
callback func()
destroyed bool
}
func (l *listener) DataChanged() {
if l.destroyed {
return
}
l.callback()
}
func (l *listener) Destroy() {
l.destroyed = true
} And so type DataItem interface {
AddListener(DataListener)
Destroy()
RemoveListener(DataListener)
}
func (b *base) Destroy() {
b.lock.Lock()
defer b.lock.Unlock()
for _, listen := range b.listeners {
listen.Destroy()
}
} Then in func (l *Label) Unbind() {
if l.textSource == nil || l.textListener == nil {
return
}
l.textSource.RemoveListener(l.textListener)
l.textSource.Destroy()
l.textListener = nil
l.textSource = nil
} |
Moved to a different setup model where we don't recreate listeners all the time. Fixes fyne-io#2125
Moved to a different setup model where we don't recreate listeners all the time. Fixes #2125
This is on |
To avoid this issue can we expose something like IsScrolling() to test if the scrolling is on before setting the data? |
I’m not quite sure if that’s relevant to this issue? This bug was resolved and closed around a year ago. If it is a request for a new feature, I think you might want to open a feature request instead. |
I am sorry and thank you for the comment provided. |
Describe the bug:
Using data binding for a
widget.List
sometimes crash while scrolling. It seems to be a race condition. The error is:To Reproduce:
Steps to reproduce the behaviour:
Device (please complete the following information):
The text was updated successfully, but these errors were encountered: