apply race condition fix

This commit is contained in:
Gregor Lohaus
2026-05-31 19:30:36 +02:00
parent 743f312921
commit dba6474491
2 changed files with 15 additions and 5 deletions

View File

@@ -180,8 +180,16 @@ public final class TerminalPane implements AutoCloseable {
/** This pane's own content revision, bumped on every change (see {@link #refresh()}). */ /** This pane's own content revision, bumped on every change (see {@link #refresh()}). */
public long contentVersion() { public long contentVersion() {
synchronized (terminal) {
return contentVersion; return contentVersion;
} }
}
long snapshotVersion() {
synchronized (terminal) {
return snapshotVersion;
}
}
public boolean kittyEnabled() { public boolean kittyEnabled() {
return kittyEnabled; return kittyEnabled;

View File

@@ -92,12 +92,13 @@ final class TerminalPaneNode extends Region {
void renderFull(boolean active) { void renderFull(boolean active) {
prepareGeometry(); prepareGeometry();
RenderStateSnapshot snapshot = pane.snapshotFull(); RenderStateSnapshot snapshot = pane.snapshotFull();
long renderedVersion = pane.snapshotVersion();
boolean withKitty = pane.kittyEnabled() && hasKittyGraphics(); boolean withKitty = pane.kittyEnabled() && hasKittyGraphics();
updateRowsFull(snapshot); updateRowsFull(snapshot);
updateKittyGraphics(snapshot, withKitty); updateKittyGraphics(snapshot, withKitty);
updateCursor(snapshot); updateCursor(snapshot);
updateBorder(active); updateBorder(active);
markDrawn(); markDrawn(renderedVersion);
} }
void renderIncremental(boolean active) { void renderIncremental(boolean active) {
@@ -113,6 +114,7 @@ final class TerminalPaneNode extends Region {
} }
RenderStateSnapshot snapshot = pane.snapshot(); RenderStateSnapshot snapshot = pane.snapshot();
long renderedVersion = pane.snapshotVersion();
int dirty = snapshot == null ? DIRTY_FULL : snapshot.dirty(); int dirty = snapshot == null ? DIRTY_FULL : snapshot.dirty();
if (dirty == DIRTY_FULL) { if (dirty == DIRTY_FULL) {
updateChangedRows(snapshot, snapshot.renderRows()); updateChangedRows(snapshot, snapshot.renderRows());
@@ -122,7 +124,7 @@ final class TerminalPaneNode extends Region {
updateKittyGraphics(snapshot, false); updateKittyGraphics(snapshot, false);
updateCursor(snapshot); updateCursor(snapshot);
updateBorder(active); updateBorder(active);
markDrawn(); markDrawn(renderedVersion);
} }
private boolean prepareGeometry() { private boolean prepareGeometry() {
@@ -578,8 +580,8 @@ final class TerminalPaneNode extends Region {
return new SourceRect(sourceX, sourceY, Math.min(sourceWidth, image.getWidth() - sourceX), Math.min(sourceHeight, image.getHeight() - sourceY)); return new SourceRect(sourceX, sourceY, Math.min(sourceWidth, image.getWidth() - sourceX), Math.min(sourceHeight, image.getHeight() - sourceY));
} }
private void markDrawn() { private void markDrawn(long renderedVersion) {
drawnContentVersion = pane.contentVersion(); drawnContentVersion = renderedVersion;
drawnWidth = pane.width(); drawnWidth = pane.width();
drawnHeight = pane.height(); drawnHeight = pane.height();
} }