From dd39e6f07bfe9ca1495553c30445bc4debac0c6d Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Thu, 7 May 2026 14:40:20 +0900 Subject: [PATCH] =?UTF-8?q?707=20=EC=83=9D=EA=B8=B0=EB=8A=94=20=ED=98=84?= =?UTF-8?q?=EC=83=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useUndoRedo.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/hooks/useUndoRedo.js b/src/hooks/useUndoRedo.js index 1567985b..777b767e 100644 --- a/src/hooks/useUndoRedo.js +++ b/src/hooks/useUndoRedo.js @@ -323,8 +323,11 @@ export function useUndoRedo() { const cells = roofs.filter((obj) => obj.cells && obj.cells.length > 0) setDrewRoofCells(cells) - // loadFromJSON 후 QPolygon/QLine 의 lengthText 가 orphan 제거되었을 수 있으므로 재생성 - // (initLines 로 새 QLine 이 만들어지면 기존 lengthText 의 parentId 가 안 맞음) + // loadFromJSON 후 QPolygon 의 내부 lines 배열은 plain object 로만 복원되므로 + // initLines() 로 실제 QLine 인스턴스를 재구축한다. + // (lengthText 는 JSON 에서 이미 복원되므로 재생성하지 않는다. + // 과거에는 addLengthText 도 함께 호출했으나, undo/redo 반복 시 숨겨진 모서리 라인의 + // 텍스트가 누적 생성되어 "707" 같은 잔존 텍스트가 화면에 나타나는 문제가 있었음) const shouldRebuildText = (poly) => poly.type === 'QPolygon' && poly.name !== 'arrow' && @@ -336,11 +339,10 @@ export function useUndoRedo() { qPolygons.forEach((polygon) => { try { polygon.initLines() - polygon.addLengthText() } catch (e) { /* skip */ } }) - // Group 내부 QPolygon(도머 등)의 lengthText 도 동일하게 재생성 + // Group 내부 QPolygon(도머 등)도 동일하게 내부 라인 인스턴스만 재구축한다. objects .filter((obj) => obj.type === 'group' && obj._objects) .forEach((group) => { @@ -349,21 +351,10 @@ export function useUndoRedo() { try { if (!child.canvas) child.canvas = canvas child.initLines?.() - child.addLengthText?.() } catch (e) { /* skip */ } } }) }) - - canvas.getObjects() - .filter((obj) => obj.type === 'QLine') - .forEach((line) => { - try { - if (typeof line.addLengthText === 'function') { - line.addLengthText() - } - } catch (e) { /* skip */ } - }) }, [canvas, rebuildObjectGraph]) const restoreAtomSnapshot = useCallback((atomSnapshot) => {