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

ListWidget with data index out of binds when modified binded data #5227

Open
2 tasks done
deoxyimran opened this issue Oct 27, 2024 · 0 comments
Open
2 tasks done

ListWidget with data index out of binds when modified binded data #5227

deoxyimran opened this issue Oct 27, 2024 · 0 comments
Labels
unverified A bug that has been reported but not verified

Comments

@deoxyimran
Copy link

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

When i modify the binded data like shrinking or growing the backing slice and call reload on the data afterwards, I get this internal error message from fyne:

2024/10/27 18:57:28 Fyne error:  Error getting current data value
2024/10/27 18:57:28   Cause: index out of bounds
2024/10/27 18:57:28   At: /home/darkc0der/go/pkg/mod/fyne.io/fyne/[email protected]/widget/label.go:165

The app doesnt crash or work abnormally afterwards, it runs just fine like before. But the error message reappears everytime I shrink the slice further due to item deletion and reload the bind...hinting that something was accessed out of binds--old indices still being kept around, maybe?

How to reproduce

Already explained in the bug description...

Screenshots

No response

Example code

dataBind = binding.BindStringList( & titles)
notes := widget.NewListWithData(
    dataBind,
    func() fyne.CanvasObject {
        return widget.NewLabel("")
    },
    func(di binding.DataItem, co fyne.CanvasObject) {
        co.( * widget.Label).Bind(di.(binding.String))
    },
)

trash := newTrashButton(trashIcoRes)
trash.onTapped = func() {
    if len(tempTitles) != 0 {
        notes.Unselect(currentItemID)
        textPane.Hide()
        tempTitles = slices.Delete(tempTitles, currentItemID, currentItemID + 1)
        tempEditorTexts = slices.Delete(tempEditorTexts, currentItemID, currentItemID + 1)
        search(titleEntry.Text)
    } else {
        notes.Unselect(currentItemID)
        textPane.Hide()
        titles = slices.Delete(titles, currentItemID, currentItemID + 1)
        editorTexts = slices.Delete(editorTexts, currentItemID, currentItemID + 1)
        dataBind.Reload()
    }
}

Fyne version

2.5.2

Go compiler version

1.21.6

Operating system and version

linux/amd64

Additional Information

No response

@deoxyimran deoxyimran added the unverified A bug that has been reported but not verified label Oct 27, 2024
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

1 participant