fix: fix destroyed callback issues in GestureRecognizer#1013
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRefactors GestureRecognizer’s gesture destruction handling to rely on Qt’s automatic signal disconnection, directly clean up gesture lists on QObject destruction, and align swipe/hold unregister behavior while removing an unsafe deleteLater call in HoldGesture. Sequence diagram for gesture QObject destruction cleanupsequenceDiagram
actor QObject
participant SwipeGesture
participant HoldGesture
participant GestureRecognizer
QObject->>SwipeGesture: destroyed
SwipeGesture->>GestureRecognizer: destroyed
GestureRecognizer->>GestureRecognizer: m_swipeGestures.removeOne
GestureRecognizer->>GestureRecognizer: m_activeSwipeGestures.removeOne
QObject->>HoldGesture: destroyed
HoldGesture->>GestureRecognizer: destroyed
GestureRecognizer->>GestureRecognizer: m_holdGestures.removeOne
GestureRecognizer->>GestureRecognizer: m_activeHoldGestures.removeOne
Sequence diagram for explicit HoldGesture unregistrationsequenceDiagram
participant GestureRecognizer
participant HoldGesture
GestureRecognizer->>HoldGesture: unregisterHoldGesture
GestureRecognizer->>GestureRecognizer: m_holdGestures.removeOne
alt gesture is active
GestureRecognizer->>GestureRecognizer: m_activeHoldGestures.removeOne
GestureRecognizer->>HoldGesture: cancelled
else gesture is not active
GestureRecognizer->>GestureRecognizer: m_activeHoldGestures.removeOne
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. |
|
TAG Bot New tag: 0.8.12 |
|
TAG Bot New tag: 0.8.13 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: deepin-wm, wineee 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 |
2 similar comments
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: deepin-wm, wineee 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 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: deepin-wm, wineee 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 in gesture recognition by simplifying destroyed-signal handling and aligning swipe/hold gesture cleanup and cancellation behavior.
Bug Fixes:
Enhancements:
Chores: