From 7fc60537758bf04e61ce614a83d534dc82623154 Mon Sep 17 00:00:00 2001 From: YOUNGHO LEE Date: Thu, 18 Jun 2026 00:32:35 +0900 Subject: [PATCH] fix: clear property-usage refs when objects are removed (incl. scene deletion) --- src/class/container.js | 4 +++- src/class/variable_container.js | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/class/container.js b/src/class/container.js index a8d01b7066..8d3b3df040 100644 --- a/src/class/container.js +++ b/src/class/container.js @@ -482,9 +482,11 @@ Entry.Container = class Container { const object = this.getObject(id); const index = objects.indexOf(object); + const removedObjectId = object.id; object.destroy(); objects.splice(index, 1); - Entry.variableContainer.removeLocalVariables(object.id); + Entry.variableContainer.removeLocalVariables(removedObjectId); + Entry.variableContainer.removeRefs(removedObjectId); Entry.engine.hideProjectTimer(); if (isPass === true) { diff --git a/src/class/variable_container.js b/src/class/variable_container.js index 5d45a83760..310a325726 100644 --- a/src/class/variable_container.js +++ b/src/class/variable_container.js @@ -3255,6 +3255,18 @@ Entry.VariableContainer = class VariableContainer { }); } + removeRefs(objectId) { + if (!objectId) { + return; + } + ['_variableRefs', '_messageRefs', '_functionRefs'].forEach((type) => { + this[type] = this[type].filter( + (ref) => !ref.object || ref.object.id !== objectId + ); + }); + this.view_ && Entry.playground.viewMode_ !== 'default' && this.updateList(); + } + addRef(type, blockData) { const wsMode = _.result(Entry.getMainWS(), 'getMode'); if (!this.view_ || wsMode !== Entry.Workspace.MODE_BOARD) {