fyne icon indicating copy to clipboard operation
fyne copied to clipboard

NewTreeWithData Rendering Issue

Open BieHDC opened this issue 1 year ago • 3 comments

Checklist

  • [X] I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • [X] This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

When making a widget.NewTreeWithData with the binding to a tree fyne sometimes doesnt render items above the selected one except for one above. See Video.

How to reproduce

  1. Run Example Code
  2. Select the 2nd item, then the 3rd, then the 4th
  3. If the bug didnt trigger, close the application and do 2. again (See Video)

Screenshots

https://github.com/fyne-io/fyne/assets/43303168/027e9cf7-bd19-4aa3-a4dc-67a8ba524e3c

Example code

package main

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/data/binding"
	"fyne.io/fyne/v2/widget"
)

func main() {
	a := app.New()
	w := a.NewWindow("BUG DEMO")
	w.Resize(fyne.NewSize(800, 600))
	w.SetContent(makeMain(a, w))
	w.Show()
	a.Run()
}

func makeMain(a fyne.App, w fyne.Window) fyne.CanvasObject {
	tree := binding.NewStringTree()
	treewg := widget.NewTreeWithData(
		tree,
		func(_ bool) fyne.CanvasObject {
			return widget.NewLabel("example str")
		},
		func(data binding.DataItem, _ bool, obj fyne.CanvasObject) {
			l := obj.(*widget.Label)
			d, err := data.(binding.String).Get()
			if err != nil {
				panic(err)
			}
			l.SetText(d)
		},
	)

	for _, str := range []string{"aaa", "bbb", "ccc", "ddd", "eee"} {
		tree.Append(binding.DataTreeRootID, str, str+str)
	}

	return container.NewPadded(treewg)
}

Fyne version

2.4.1

Go compiler version

1.21.3

Operating system and version

linux/amd64

Additional Information

Does NOT happen with widget.NewListWithData

BieHDC avatar Oct 27 '23 17:10 BieHDC

The example code on https://developer.fyne.io/collection/tree exhibits the same behaviour (although it's worth noting the container.NewPadded() in the OP makes the upper portion disappear completely sometimes as well).

dozn avatar Oct 30 '23 13:10 dozn

go 1.21.5
 fyne.io/fyne/v2 v2.4.3 
macOS 14.0

Also, when placing two tree controls on the interface, one of them may work properly while the other sometimes encounters this bug and sometimes doesn't. This bug usually appears when a new execution interface is launched.

billytoe avatar Jan 14 '24 14:01 billytoe

Can confirm this bug is occurring on both Windows and Linux:

OS Fyne Go
Windows 10 22H2 Fyne 2.4.5 Go 1.22.1
Ubuntu 22.04.4 LTS Fyne 2.4.5 Go 1.22.1

The bug happens regularly around ever 5 times I start my app. I was planning to use this widget, so keeping my fingers crossed for a fix soon.

ErikKalkoken avatar May 31 '24 20:05 ErikKalkoken

I also found this issue on unbuntu18, and the triggering frequency is still very high. Relevant records。 I used version 2.5 for the relevant records. Detailed description reference: https://github.com/fyne-io/fyne/issues/5082 When can this be resolved, or is there any way to avoid it

LidiYuan avatar Aug 19 '24 12:08 LidiYuan

I also found this issue on unbuntu18, and the triggering frequency is still very high. Relevant records。 I used version 2.5 for the relevant records. Detailed description reference: #5082 When can this be resolved, or is there any way to avoid it

The no data variant (widget.NewTree()) works fine, so one way to avoid it is to use that variant until the bug is fixed. At least that is what I did in my apps.

ErikKalkoken avatar Aug 19 '24 12:08 ErikKalkoken