From 3cced3b8ec68026ed198f11b0990bf960574a826 Mon Sep 17 00:00:00 2001 From: "tianshilin@uniontech.com" Date: Wed, 28 Oct 2026 06:16:57 +0800 Subject: [PATCH] fix: delay nav mask refresh after rotation for stale geometry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Root cause: onCurrentRotationChanged calls currentImage.updateMask() immediately, but targetImage has a 50ms delayUpdate timer before reload, so paintedWidth/paintedHeight are still pre-rotation values 2. Fix: add rotationRefreshTimer (200ms) to defer updateMask() until after targetImage finishes reloading with rotated pixel dimensions 3. Impact: only affects navigation mask position after rotation; existing onPaintedWidthChanged/onPaintedHeightChanged signals provide self- correction as a fallback Log: Fixed navigation window mask position error after rotating zoomed image Influence: 1. Test zoom in then rotate image, verify nav mask position is correct 2. Test rapid consecutive rotations, verify mask settles correctly 3. Test rotation on image smaller than window, verify no nav shown fix: 修复旋转后导航窗口蒙皮位置错误 1. 根因:onCurrentRotationChanged 立即调用 currentImage.updateMask(), 但 targetImage 有 50ms delayUpdate 延迟重载,paintedWidth/ paintedHeight 仍为旋转前值,导致蒙皮位置计算使用过时数据 2. 方案:新增 rotationRefreshTimer(200ms)延迟调用 updateMask(), 等待 targetImage 完成重载后再刷新蒙皮位置 3. 影响:仅影响旋转后导航窗口蒙皮位置;已有的 onPaintedWidthChanged/onPaintedHeightChanged 信号提供自纠正兜底 Log: 修复放大图片旋转后导航窗口蒙皮位置错误 Influence: 1. 测试放大后旋转图片,验证导航蒙皮位置正确 2. 测试快速连续旋转,验证蒙皮最终位置正确 3. 测试小于窗口的图片旋转,验证不显示导航窗口 PMS: BUG-373837 --- src/qml/NavigationWidget.qml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/qml/NavigationWidget.qml b/src/qml/NavigationWidget.qml index fa74486d7..930006c29 100644 --- a/src/qml/NavigationWidget.qml +++ b/src/qml/NavigationWidget.qml @@ -197,6 +197,18 @@ Item { onTriggered: refreshNaviMaskImpl() } + // 旋转后主视图 targetImage 有 50ms delayUpdate 延迟重载,立即刷新蒙皮 + // 会使用旋转前的 paintedWidth/paintedHeight,导致蒙皮位置错误 + // 200ms = 50ms delayUpdate + ~150ms 异步图片重载余量 + Timer { + id: rotationRefreshTimer + + interval: 200 + repeat: false + + onTriggered: currentImage.updateMask() + } + Connections { function onPaintedHeightChanged() { refreshNaviMask(); @@ -280,7 +292,7 @@ Item { var temp = currentImage.source; currentImage.source = ""; currentImage.source = temp; - currentImage.updateMask(); + rotationRefreshTimer.restart(); } function onCurrentSourceChanged() {