fix: delay drag activation to fix first drag icon not showing in treeland#1670
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideDelays activation of the drag state until after the drag image is captured, and explicitly deactivates drag when no active drag is in progress to fix the first-drag icon issue on treeland without regressing other platforms. Sequence diagram for delayed drag activation after image capturesequenceDiagram
actor User
participant DragItem
participant Qt
participant Drag
User->>DragItem: startDrag
DragItem->>DragItem: [grab image]
DragItem->>Qt: Qt.callLater(callback)
Qt->>Drag: Drag.active = true
alt drag not active
DragItem->>Drag: Drag.active = false
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider handling the case where the drag is cancelled or
activebecomes false while the image grab is still in progress, so that theQt.callLatercallback does not mistakenly setDrag.active = trueafter the fact. - The previous code set
Drag.active = active, whereas the new logic always sets it totrueafter a successful grab; double-check whether you still need to respect theactiveflag in some scenarios (e.g., reuse of this function for non-drag cases).
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider handling the case where the drag is cancelled or `active` becomes false while the image grab is still in progress, so that the `Qt.callLater` callback does not mistakenly set `Drag.active = true` after the fact.
- The previous code set `Drag.active = active`, whereas the new logic always sets it to `true` after a successful grab; double-check whether you still need to respect the `active` flag in some scenarios (e.g., reuse of this function for non-drag cases).Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
The issue occurred because under the treeland environment, the drag icon was not displayed during the first drag attempt. This was due to incorrectly setting `Drag.active` before the image grab operation completed. The fix moves the drag activation logic to occur only after the image is successfully grabbed via the callback, and explicitly deactivates drag when the grab fails or is not ready. Log: Fixed first drag icon not showing under treeland Influence: 1. Test dragging quick panel items in treeland and verify icon appears on first drag 2. Verify drag behavior remains correct in other desktop environments (e.g., X11) 3. Test drag with various item types and positions 4. Verify no regressions in drag cancellation or re-drag scenarios fix: 修复treeland下首次拖拽不显示图标问题 在treeland环境下,首次拖拽时拖拽图标未能显示。原因是在图像截取操作完成前 就错误地设置了 `Drag.active` 状态。修复方案是仅在图像截取成功后的回调函 数中激活拖拽,并在截取失败或未就绪时显式取消拖拽。 Log: 修复treeland下首次拖拽图标不显示的问题 Influence: 1. 在treeland环境下测试拖拽快速面板项目,验证首次拖拽时图标正常显示 2. 验证其他桌面环境(如X11)下拖拽行为仍然正确 3. 测试不同项目类型和位置的拖拽功能 4. 验证拖拽取消或重新拖拽场景无回归问题 PMS: BUG-339333
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 当前代码已为最佳实践,无需进一步修改 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
The issue was that on treeland, the first drag attempt did not display
the icon because
Drag.activewas set totrueimmediately withoutwaiting for the drag image to be fully captured. By moving
Drag.active = trueinto aQt.callLater()callback after the image grabcompletes, we ensure the drag image is ready before activating the drag.
Additionally, setting
Drag.active = falsewhen drag is not activeprevents premature drag activation.
Log: Fixed first drag icon not showing issue on treeland
Influence:
regression
conditions
fix: 修复 treeland 下首次拖拽图标不显示的问题
问题在于 treeland 环境下,首次拖拽时未等待拖拽图像完全捕获就
立即设置了
Drag.active = true。通过在图像抓取完成后的回调中使用Qt.callLater()延迟设置Drag.active = true,确保拖拽图像就绪后再激活拖拽。同时,在非拖拽状态下设置
Drag.active = false,避免提前激活拖拽。Log: 修复 treeland 下首次拖拽图标不显示的问题
Influence:
Summary by Sourcery
Bug Fixes: