mirror of
https://github.com/rivo/tview.git
synced 2026-04-27 05:45:49 +03:00
[GH-ISSUE #262] TreeView panics with 'index out of range' error #203
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#203
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @urandom on GitHub (Apr 6, 2019).
Original GitHub issue: https://github.com/rivo/tview/issues/262
For some reason, during TreeView's process, the code tries to get a node outside the index. The problem is that the tree does not have any nodes yet.
The stack trace:
The simplest fix might be to return early from the process method if there are no nodes.
@rivo commented on GitHub (Apr 6, 2019):
I'm having trouble following this stack trace. The line numbers don't seem to line up with the current code. And
TreeViewactually doesn't do anything if there is no root node, see here:github.com/rivo/tview@9d616aee87/treeview.go (L542)Are you using the latest commit?
@urandom commented on GitHub (Apr 7, 2019):
This is an up-to-date stack trace:
@urandom commented on GitHub (Apr 7, 2019):
On further investigation there is at least one node in the tree at this point, and the tree is set to level 1, and has finished being updated with more nodes via a QueueUpdateDraw call (which causes the Draw call)
The panic itself is caused by the root node being set as current (via SetCurrentNode), while also being invisible, and not having any children
@rivo commented on GitHub (May 13, 2019):
I made a change which I believe will fix the panic that you reported. Please have a look and let me know if it works now.
@urandom commented on GitHub (May 14, 2019):
I can't seem to reproduce the problem with your latest change.