From 7a0fec2c2f2d52d80443ff679d7fe50ba2755c1b Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 23 Apr 2026 07:44:33 -0500 Subject: [PATCH] Maybe fix a buffer deletion issue? --- .../render/openGl/glObject/buffer/GLBuffer.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java index d74fe3e73..f97a74d6b 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/buffer/GLBuffer.java @@ -156,18 +156,17 @@ public class GLBuffer implements AutoCloseable protected void destroyAsync() { - if (this.id == 0) - { - // the buffer has already been closed - return; - } - - // lock to prevent the render thread from accessing the buffer's ID // while we are removing it long writeStamp = renderStampLock.writeLock(); try { + if (this.id == 0) + { + // the buffer has already been closed + return; + } + final int idToDelete = this.id; // saving the ID to a separate variable is necessary so it can be captured by the lambda // mark the old data is invalid before deleting to prevent a rare race condition