Skip to content

Commit 2fa16c7

Browse files
committed
Clean up better when cancelling the supervisor
Avoid a ghost opened state
1 parent e193e66 commit 2fa16c7

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

interfaces/src/main/kotlin/com/noxcrew/interfaces/view/AbstractInterfaceView.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,18 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, T : Interfa
269269
decoratingJob.set(null)
270270
transformingJob.set(null)
271271

272+
// Queue up any unfinished transforms back up!
273+
queuedTransforms += pendingTransforms
274+
pendingTransforms.clear()
275+
val oldLazy = pendingNonBlockingTransforms
276+
pendingNonBlockingTransforms = ConcurrentLinkedQueue()
277+
queuedTransforms += oldLazy
278+
279+
// Clear up all the state that might be half-finished!
280+
lazyElements.clear()
281+
queueAllTriggers.set(false)
282+
debouncedRender.set(false)
283+
272284
// Test if a background menu should be opened
273285
if (reason in REOPEN_REASONS && !player.isDead) {
274286
InterfacesListeners.INSTANCE.reopenInventory(player)
@@ -524,7 +536,7 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, T : Interfa
524536

525537
if (instantTransforms.isEmpty() || lazyTransforms.isEmpty()) {
526538
// If either category is empty we run everything immediately
527-
pendingTransforms.addAll(transforms)
539+
pendingTransforms.addAll(newTransforms)
528540

529541
// If only the instant transforms are empty, we render first!
530542
if (instantTransforms.isEmpty() && renderIfEmpty) {
@@ -587,7 +599,7 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, T : Interfa
587599
// After we complete a render we add any lazy transforms to the pending
588600
// list which may cause us to keep rendering even after the re-render
589601
val oldLazy = pendingNonBlockingTransforms
590-
pendingNonBlockingTransforms = ConcurrentLinkedQueue<AppliedTransform<P>>()
602+
pendingNonBlockingTransforms = ConcurrentLinkedQueue()
591603
pendingTransforms += oldLazy
592604
}
593605
}

interfaces/src/main/kotlin/com/noxcrew/interfaces/view/InterfaceView.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public interface InterfaceView {
3939
/** Re-opens only if this menu should still be. */
4040
public suspend fun reopenIfIntended(): Boolean {
4141
if (!shouldStillBeOpened) return false
42+
if (isOpen()) return false
4243
return reopen(null)
4344
}
4445

0 commit comments

Comments
 (0)