mirror of
https://github.com/rivo/tview.git
synced 2026-04-27 05:45:49 +03:00
[GH-ISSUE #563] App is crashing because of a textView #413
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#413
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 @inmylo on GitHub (Feb 8, 2021).
Original GitHub issue: https://github.com/rivo/tview/issues/563
My application has a textView, which is being updated very often, for example each millisecond. It sometimes crashes when I try to close a modal window with
app.SetRoot(pages, true). I've figured out, thattextview.go'st.bufferis sometimes empty, so I tried to add an additional check and it seems to help. You can choose a more efficient way if such exists.Created a PR #562
Some time ago I got a similar error at the line
826str := t.buffer[line.Line][line.Pos:line.NextPos]- maybe it should be fixed too.Panic's error:
@rivo commented on GitHub (Feb 17, 2021):
How do you update the
TextView's content? Do you write to it using theio.Writerinterface or do you callSetText()on it?@inmylo commented on GitHub (Feb 17, 2021):
Currently I do it this way:
But I'm not sure whether I have to call
Draw()every iteration, but it also seems to help to prevent crashing. Maybe it can be avoided to decrease CPU load@rivo commented on GitHub (Apr 27, 2021):
When you call
app.Draw(), it will not redraw immediately but queue a redraw request to be completed at the next possible opportunity (from within the main loop). Doing this every 32 milliseconds might lead that request queue to become too big if the loop can't keep up.Also, the
SetText()function is not thread-safe and shouldn't be called in a non-main goroutine.I would suggest that you rather do something like this:
If you still get crashes with this code, please post some (short) code that reproduces that issue so I can get to the root of it.