Skip to content

Commit

Permalink
Hopefully fix race condition with filtered rows
Browse files Browse the repository at this point in the history
  • Loading branch information
NotNite committed Nov 15, 2024
1 parent 381e7da commit f5b5566
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Alpha/Gui/Windows/ExcelWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -542,16 +542,18 @@ 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
var newHeight = 0f;
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;

Expand Down

0 comments on commit f5b5566

Please sign in to comment.