mirror of
https://github.com/rivo/tview.git
synced 2026-04-28 14:25:58 +03:00
[GH-ISSUE #690] QueueUpdate(Draw) deadlocks in goroutine #504
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#504
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 @craftyguy on GitHub (Jan 19, 2022).
Original GitHub issue: https://github.com/rivo/tview/issues/690
I'm trying to update the text in a textview, and wrapping it in a
QueueUpdate(orQueueUpdateDraw), per the wiki page on concurrency, deadlocks 100% of the time:The wiki says I should call
Application.Drawin the "changed" handler for a textview, however this does not result in the screen being updated with any changes when usingSetText:What's the correct way to update a textview from a goroutine?
I'm using Go 1.17.4 on Alpine Linux (amd64)
@darkhz commented on GitHub (Jan 21, 2022):
Hello @craftyguy,
The first code snippet does not particularly deadlock for me when I tried it. The reason why the screen is not being updated is because you put your textview
tvin a newly created Application:but you're using another already created Application instance (app, which was not initialized by calling Run() to begin with) to concurrently update your textview:
So your textview will be updated in a different Application than you originally intended. Therefore, use the same Application instance you declared before for all your UI related operations.
Here is the corrected code:
This worked as intended when I tested it.
@craftyguy commented on GitHub (Jan 21, 2022):
oof, I see the problem now. Sorry for the noise and thank you for taking the time to explain my problem :)