Skip to content

Commit b4f76ed

Browse files
committed
fix: guard updateCache() for uncached blocks and re-cache on restore from trash
1 parent 0a8008a commit b4f76ed

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

js/activity.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4266,6 +4266,19 @@ class Activity {
42664266
const blk = this.blocks.dragGroup[b];
42674267
this.blocks.blockList[blk].trash = false;
42684268
this.blocks.moveBlockRelative(blk, dx, dy);
4269+
4270+
// Re-cache the container if it was uncached to save
4271+
// memory in sendStackToTrash().
4272+
const block = this.blocks.blockList[blk];
4273+
if (block.container && !block.container.bitmapCache) {
4274+
block.container.cache(
4275+
0,
4276+
0,
4277+
Math.max(block.width, 1),
4278+
Math.max(block.height, 1)
4279+
);
4280+
}
4281+
42694282
this.blocks.blockList[blk].show();
42704283
}
42714284

js/block.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,13 @@ class Block {
399399
updateCache() {
400400
const that = this;
401401
return new Promise((resolve, reject) => {
402+
// If the container has no active bitmap cache (e.g., trashed
403+
// blocks whose cache was freed), skip the update silently.
404+
if (that.container && !that.container.bitmapCache) {
405+
resolve();
406+
return;
407+
}
408+
402409
let loopCount = 0;
403410
const MAX_RETRIES = 15;
404411
const INITIAL_DELAY = 100;

0 commit comments

Comments
 (0)