Skip to content

[fix] clear property-usage refs when objects are removed (incl. scene deletion)#3076

Open
205sla wants to merge 1 commit into
entrylabs:developfrom
205sla:fix/variable-usage-object-delete
Open

[fix] clear property-usage refs when objects are removed (incl. scene deletion)#3076
205sla wants to merge 1 commit into
entrylabs:developfrom
205sla:fix/variable-usage-object-delete

Conversation

@205sla

@205sla 205sla commented Jun 17, 2026

Copy link
Copy Markdown

오브젝트를 삭제할 때 변수/리스트/신호/함수 속성 패널의 "사용된 오브젝트" 목록에서 해당 오브젝트가 사라지지 않는 버그를 수정합니다.

Entry.VariableContainer의 사용처 ref 배열(_variableRefs, _messageRefs, _functionRefs)에서 삭제된 오브젝트의 ref를 제거합니다. 오브젝트를 직접 삭제하는 경우와 장면 삭제로 오브젝트가 함께 제거되는 경우를 모두 처리합니다.

Why

변수/리스트/신호/함수 속성 패널은 위 세 ref 배열을 기반으로 "이 속성을 사용하는 오브젝트"를 표시합니다.

블록을 삭제하면 dataDestroy 이벤트가 removeRef()를 호출하므로 사용처 ref가 정상적으로 제거됩니다. 그러나 오브젝트를 직접 삭제하거나, 장면 삭제가 removeObject(object, true)로 그 장면의 오브젝트를 제거하는 경우에는 오브젝트의 스크립트 블록이 destroy되지 않아 dataDestroy가 발생하지 않습니다. 이때 삭제된 오브젝트의 ref가 배열에 그대로 남아, 이미 없는 오브젝트가 사용처 목록에 계속 표시되고 오브젝트/블록 참조가 메모리에 살아남습니다.

Implementation

  1. src/class/variable_container.js에 Entry.VariableContainer#removeRefs(objectId)를 추가했습니다. _variableRefs, _messageRefs, _functionRefs를 오브젝트 id 기준으로 필터링하고, default 뷰 모드가 아닐 때 목록을 갱신합니다.
  2. src/class/container.js의 Entry.Container#removeObject()를 수정했습니다. object.destroy() 전에 removedObjectId를 캡처하고, removeLocalVariables(removedObjectId)에 이어 removeRefs(removedObjectId)를 isPass === true early return 앞에서 호출합니다. 장면 삭제가 removeObject(object, true)를 거치므로 이 호출 위치가 중요합니다.

범위:

  • scene.js 변경 없음.
  • 렌더/카운트 로직 변경 없음.
  • object.destroy()/script.destroy() 동작 변경 없음.
  • 의존성/포매팅 변경 없음.

test video: YouTube

Copilot AI review requested due to automatic review settings June 17, 2026 16:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds cleanup of variable/message/function references when an object is removed, preventing stale references from lingering in the variable container UI/state.

Changes:

  • Introduced VariableContainer.removeRefs(objectId) to purge ref entries tied to a removed object.
  • Updated object removal flow to capture object.id before destroy() and invoke both local variable cleanup and ref cleanup.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/class/variable_container.js Adds removeRefs() to filter out refs connected to a removed object and refresh the list in non-default view modes.
src/class/container.js Ensures object id is captured pre-destroy and triggers removeRefs() after object removal.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +3262 to +3266
['_variableRefs', '_messageRefs', '_functionRefs'].forEach((type) => {
this[type] = this[type].filter(
(ref) => !ref.object || ref.object.id !== objectId
);
});
Comment thread src/class/variable_container.js Outdated
(ref) => !ref.object || ref.object.id !== objectId
);
});
Entry.playground.viewMode_ !== 'default' && this.updateList();
@205sla 205sla force-pushed the fix/variable-usage-object-delete branch from 5981902 to 7fc6053 Compare June 17, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants