[PR #328] [CLOSED] Use Lock to Clear() TextView #909

Closed
opened 2026-03-04 01:08:31 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/rivo/tview/pull/328
Author: @khepin
Created: 7/26/2019
Status: Closed

Base: masterHead: threadsafer-textview


📝 Commits (1)

  • f92fc57 Use Lock to Clear() TextView

📊 Changes

1 file changed (+2 additions, -0 deletions)

View changed files

📝 textview.go (+2 -0)

📄 Description

Currently it's possible to call Clear() on a TextView while it is currently Draw()ing.
This would result in the view having an empty buffer when it is iterating through the
lines on line 839:

text := t.buffer[index.Line][index.Pos:index.NextPos]

This will then cause a panic and crash the whole program.

Since Draw() already locks, making sure that Clear() also does will prevent
the buffer from disappearing in the middle of a draw.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/rivo/tview/pull/328 **Author:** [@khepin](https://github.com/khepin) **Created:** 7/26/2019 **Status:** ❌ Closed **Base:** `master` ← **Head:** `threadsafer-textview` --- ### 📝 Commits (1) - [`f92fc57`](https://github.com/rivo/tview/commit/f92fc57ddb302d02ce1da0fd61356335c6cbf1df) Use Lock to Clear() TextView ### 📊 Changes **1 file changed** (+2 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `textview.go` (+2 -0) </details> ### 📄 Description Currently it's possible to call `Clear()` on a TextView while it is currently `Draw()`ing. This would result in the view having an empty buffer when it is iterating through the lines on line 839: `text := t.buffer[index.Line][index.Pos:index.NextPos]` This will then cause a panic and crash the whole program. Since `Draw()` already locks, making sure that `Clear()` also does will prevent the buffer from disappearing in the middle of a draw. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-04 01:08:31 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#909
No description provided.