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

View File

@@ -92,12 +92,13 @@ final class TerminalPaneNode extends Region {
void renderFull(boolean active) {
prepareGeometry();
RenderStateSnapshot snapshot = pane.snapshotFull();
long renderedVersion = pane.snapshotVersion();
boolean withKitty = pane.kittyEnabled() && hasKittyGraphics();
updateRowsFull(snapshot);
updateKittyGraphics(snapshot, withKitty);
updateCursor(snapshot);
updateBorder(active);
markDrawn();
markDrawn(renderedVersion);
}
void renderIncremental(boolean active) {
@@ -113,6 +114,7 @@ final class TerminalPaneNode extends Region {
}
RenderStateSnapshot snapshot = pane.snapshot();
long renderedVersion = pane.snapshotVersion();
int dirty = snapshot == null ? DIRTY_FULL : snapshot.dirty();
if (dirty == DIRTY_FULL) {
updateChangedRows(snapshot, snapshot.renderRows());
@@ -122,7 +124,7 @@ final class TerminalPaneNode extends Region {
updateKittyGraphics(snapshot, false);
updateCursor(snapshot);
updateBorder(active);
markDrawn();
markDrawn(renderedVersion);
}
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));
}
private void markDrawn() {
drawnContentVersion = pane.contentVersion();
private void markDrawn(long renderedVersion) {
drawnContentVersion = renderedVersion;
drawnWidth = pane.width();
drawnHeight = pane.height();
}