fix: fix destroyed callback issues in GestureRecognizer#1013
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts GestureRecognizer’s lifecycle handling by replacing destroyed-signal-based unregister calls with direct list cleanup lambdas, simplifying connection management, aligning hold-gesture cancellation semantics with swipe, and relying on Qt’s parent/child destruction instead of manual deleteLater. Sequence diagram for gesture destruction cleanup in GestureRecognizersequenceDiagram
participant SwipeGesture
participant GestureRecognizer
SwipeGesture ->> GestureRecognizer: destroyed
GestureRecognizer ->> GestureRecognizer: m_swipeGestures.removeOne(gesture)
GestureRecognizer ->> GestureRecognizer: m_activeSwipeGestures.removeOne(gesture)
Sequence diagram for unregisterHoldGesture behavior in GestureRecognizersequenceDiagram
participant Client
participant GestureRecognizer
participant HoldGesture
Client ->> GestureRecognizer: unregisterHoldGesture(gesture)
GestureRecognizer ->> GestureRecognizer: m_holdGestures.removeOne(gesture)
GestureRecognizer ->> GestureRecognizer: m_activeHoldGestures.removeOne(gesture)
alt gesture_was_active
GestureRecognizer ->> HoldGesture: cancelled
end
GestureRecognizer ->> HoldGesture: deleteLater()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1. Replace destroyed callback with direct list cleanup lambda to avoid calling unregister on a being-destroyed object which emits cancelled signal and calls deleteLater 2. Remove m_destroyConnections as Qt auto-disconnects destroyed signal 3. Fix unregisterHoldGesture to clean m_activeHoldGestures and emit cancelled only when gesture was active, matching swipe behavior 4. Remove deleteLater in HoldGesture destructor as child objects are auto-destroyed by Qt parent mechanism Log: Fixed unsafe destroyed callback behavior in gesture recognition Influence: 1. Test gesture unregister during active gesture recognition 2. Test HoldGesture lifecycle and timer behavior 3. Test SwipeGesture unregister with active gestures fix: 修复GestureRecognizer中destroyed回调相关问题 1. 将destroyed回调改为直接列表清理lambda,避免在对象销毁过程中调用unregister导致发射cancelled信号和deleteLater 2. 移除m_destroyConnections,Qt会自动断开destroyed信号连接 3. 修复unregisterHoldGesture补充m_activeHoldGestures清理,仅在手势活跃时发射cancelled,与swipe版本对称 4. 移除HoldGesture析构函数中的deleteLater,子对象由Qt父对象机制自动销毁 Log: 修复手势识别中destroyed回调的不安全行为 Influence: 1. 测试手势识别期间的手势注销 2. 测试HoldGesture生命周期和定时器行为 3. 测试活跃状态下SwipeGesture的注销 Fixes: #WM-32
cacfbc3 to
463cc80
Compare
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: deepin-wm 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 |
1 similar comment
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: deepin-wm 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 |
Summary
Fix multiple issues related to the
destroyedsignal callback inGestureRecognizer:unregisteron a being-destroyed object which would emitcancelledsignal and calldeleteLateron itm_destroyConnections— Qt auto-disconnectsdestroyedsignal connections, so manual management is unnecessaryunregisterHoldGestureto cleanm_activeHoldGestures— Now matches swipe behavior: emitcancelledonly when gesture was activedeleteLaterinHoldGesturedestructor — Child objects are auto-destroyed by Qt parent mechanismTest Plan
Summary by Sourcery
Resolve lifecycle issues with gesture objects by simplifying destroyed-signal handling and aligning unregister behavior for swipe and hold gestures.
Bug Fixes:
Enhancements: