Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/module/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export class HealthEstimateHooks {
* HP storing code for canvas load or token created
*/
static onCanvasReady() {
// Clear cache on scene change to remove stale references to destroyed PIXI objects
game.healthEstimate._cache = {};

canvas.interface.healthEstimate = canvas.interface.addChild(new PIXI.Container());
const { width, height } = canvas.dimensions;
canvas.interface.healthEstimate.width = width;
Expand Down Expand Up @@ -108,7 +111,12 @@ export class HealthEstimateHooks {
const estimate = game.healthEstimate._cache[tokenDocument.id];
if (!estimate) return;
delete game.healthEstimate._cache[tokenDocument.id];
canvas.interface.healthEstimate.removeChild(estimate);

// Remove from parent and destroy (for actual token deletions)
// Note: Scene changes are handled by onCanvasReady clearing the cache
if (estimate.parent) {
estimate.parent.removeChild(estimate);
}
estimate.destroy();
}

Expand Down