Fix for DataTable race-condition crash (#1962)

* Fix for DataTable race-condition crash

* Update CHANGELOG.md
This commit is contained in:
darrenburns
2023-03-07 13:01:06 +00:00
committed by GitHub
parent 85f26e22d0
commit 1b06e50f10
2 changed files with 7 additions and 3 deletions

View File

@@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- Fixed bug that prevented app pilot to press some keys https://github.com/Textualize/textual/issues/1815
- DataTable race condition that caused crash https://github.com/Textualize/textual/pull/1962
## [0.13.0] - 2023-03-02

View File

@@ -1069,6 +1069,12 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
console = self.app.console
for row_key in new_rows:
row_index = self._row_locations.get(row_key)
# The row could have been removed before on_idle was called, so we
# need to be quite defensive here and don't assume that the row exists.
if row_index is None:
continue
row = self.rows.get(row_key)
if row.label is not None:
@@ -1080,9 +1086,6 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
self._label_column.content_width, label_content_width
)
if row_index is None:
continue
for column, renderable in zip(self.ordered_columns, cells_in_row):
content_width = measure(console, renderable, 1)
column.content_width = max(column.content_width, content_width)