Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for DataTable race-condition crash #1962

Merged
merged 2 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 6 additions & 3 deletions src/textual/widgets/_data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,12 @@ def _update_dimensions(self, new_rows: Iterable[RowKey]) -> None:
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:
Expand All @@ -1080,9 +1086,6 @@ def _update_dimensions(self, new_rows: Iterable[RowKey]) -> None:
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)
Expand Down