diff --git a/Alpha/Gui/Windows/ExcelWindow.cs b/Alpha/Gui/Windows/ExcelWindow.cs index b88f2f8..8753865 100644 --- a/Alpha/Gui/Windows/ExcelWindow.cs +++ b/Alpha/Gui/Windows/ExcelWindow.cs @@ -542,7 +542,9 @@ private void DrawSheet(float width) { ImGui.PopID(); } - var actualRowCount = this.filteredRows?.Count ?? (int) rowCount; + // Copy to a variable to avoid a race condition + var filteredRows = this.filteredRows; + var actualRowCount = filteredRows?.Count ?? (int) rowCount; var clipper = new ListClipper(actualRowCount, itemHeight: this.itemHeight ?? 0); // Sheets can have non-linear row IDs, so we use the index the row appears in the sheet instead of the row ID @@ -550,8 +552,8 @@ private void DrawSheet(float width) { var shouldPopColor = false; foreach (var i in clipper.Rows) { var rowData = this.rowMap[i]; - if (this.filteredRows is not null) { - rowData = this.filteredRows[i]; + if (filteredRows is not null) { + rowData = filteredRows[i]; } var (rowId, subrowId) = rowData;