Open shangdan1987 opened 1 year ago
Please provide full code that we can compile to replicate the issue. A tree missing all of those callbacks is impossible to work with.
@andydotxyz test00.zip The attachment is a compiled simplified demo, and I confirm that the phenomenon can still be replicated. The approximate steps for replication are as follows: 1. Start and run the app, click on sub tree and pubtree respectively, and TreeNode will display normally. 2. Place other exe windows at the top (such as entering the vscode IDE),Wait for about 1 minute, and then enter the demo app, click on sub tree and pubtree respectively. Sometimes the TreeNode of a sub tree disappears, and sometimes the TreeNode of a pub tree disappears. Thank you.
Waiting for about 1 minute seems to be the key factor
I am sure you appreciate we don't download user contributed exe files and run them on our computers. The source code that demonstrates the problem is what we need, as short as possible. It helps us locate the problem and the shorter it is the faster we can track it down.
The test00.zip only contains the demo source code files, not the exe files @andydotxyz Thank you.
Can you tell me if this phenomenon is a bug in Flyne,Thank you. @andydotxyz
Please stop pinging me - this is a community project and by asking me to review every message you are missing the chance for our other contributors to help.
As described in the form we ask people to add reproducible minimal examples in the bug report - not .exe and not .zip bundles either.
The behaviour you are describing could be caused by re-using node IDs which must be unique to your tree.
Please check your code carefully and if you still see the issue add the shortest possible code that demonstrates it (pasting the main.go content inline).
Checklist
Describe the bug
In the video, there is a random occurrence of sub and pub trees, and the TreeNode automatically disappears. In the early stages of program operation, the TreeNode display is completely normal, but after the app has been running on standby for a period of time, this situation will occur, such as the Root losing cache data.
How to reproduce
https://github.com/fyne-io/fyne/assets/24599292/e09da906-a0fe-4215-af65-26b1aa500266
Screenshots
No response
Example code
import ( "fmt"
)
type cfg struct { W fyne.Window pubtree, subtree *widget.Tree }
var Cfg cfg
func main() { myApp := app.New() myWindow := myApp.NewWindow("自制tools") Cfg.W = myWindow tabs := container.NewAppTabs( container.NewTabItem("pubilc 主题 ", publish_ui()), container.NewTabItem("subScribe 主题", subScribe_ui()), ) tabs.SetTabLocation(container.TabLocationLeading) container := container.NewBorder(nil, nil, nil, nil, tabs) myWindow.SetContent(container) myWindow.Resize(fyne.NewSize(700, 600)) myWindow.ShowAndRun() } func subScribe_ui() fyne.Container { // 创建一个空的tree组件 tree2 := widget.NewTree(nil, nil, nil, nil) Cfg.subtree = tree2 tree2.Root = "subScribe" // 创建空节点,节点是个Label组件 tree2.CreateNode = func(branch bool) (o fyne.CanvasObject) { return container.NewHBox(widget.NewLabel("none"), layout.NewSpacer(), widget.NewButton("移除", func() { fmt.Println("触发了移除按钮") })) } // 给每个节点的Label组件设置文本 tree2.UpdateNode = func(uid widget.TreeNodeID, branch bool, node fyne.CanvasObject) { l := node.(fyne.Container).Objects[0].(widget.Label) l.SetText(uid) if !branch { b := node.(fyne.Container).Objects[2].(*widget.Button) b.Hidden = true } } // 判断是否是分支节点 tree2.IsBranch = func(uid widget.TreeNodeID) (ok bool) { if uid == "subScribe" { return true } return false }
} func (c cfg) Subscribe_tree() widget.Tree { Cfg.subtree.ChildUIDs = func(uid widget.TreeNodeID) (c1 []widget.TreeNodeID) { return []string{"123", "456", "haha", "demo/test/1"} } Cfg.subtree.Refresh() return Cfg.subtree }
func publish_ui() fyne.Container { tree2 := widget.NewTree(nil, nil, nil, nil) tree2.Root = "publish" tree2.CreateNode = func(branch bool) (o fyne.CanvasObject) { return widget.NewLabel("") } // 给每个节点的Label组件设置文本 tree2.UpdateNode = func(uid widget.TreeNodeID, branch bool, node fyne.CanvasObject) { l := node.(widget.Label) l.SetText(uid) } // 判断是否是分支节点 tree2.IsBranch = func(uid widget.TreeNodeID) (ok bool) { if uid == "" || uid == "publish" { return true } return false } tree2.OpenBranch("publish") Cfg.pubtree = tree2 Cfg.PubTreeTab()
} func (c cfg) PubTreeTab() widget.Tree { Cfg.pubtree.ChildUIDs = func(uid widget.TreeNodeID) (c1 []widget.TreeNodeID) { return []string{"123", "456", "haha", "demo/test/1"} } Cfg.pubtree.Refresh() return Cfg.pubtree }
Fyne version
2.3.4
Go compiler version
1.19.3
Operating system and version
win 11
Additional Information
After switching between the foreground and background of the application window, TreeNode will automatically display, but after a period of standby, TreeNode will still disappear again No response