fix: add null check for QDrag after exec in DTabBarPrivate::startDrag#760
fix: add null check for QDrag after exec in DTabBarPrivate::startDrag#76018202781743 wants to merge 1 commit into
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds a null check on the QPointer after exec() in DTabBarPrivate::startDrag() to prevent dereferencing a deleted drag object and causing a SIGSEGV. Sequence diagram for updated DTabBarPrivate::startDrag drag handlingsequenceDiagram
participant DTabBarPrivate
participant QDrag
participant QtDnDFramework
DTabBarPrivate->>QDrag: exec()
QDrag->>QtDnDFramework: startDrag
alt drag object is deleted during exec
QtDnDFramework-->>QDrag: delete
QDrag-->>DTabBarPrivate: exec() returns
DTabBarPrivate->>DTabBarPrivate: [if !drag] return
else drag object survives
QDrag-->>DTabBarPrivate: exec() returns
DTabBarPrivate->>DTabBarPrivate: [if drag]
DTabBarPrivate->>QDrag: target()
DTabBarPrivate->>DTabBarPrivate: tabReleaseRequested / other post-drag logic
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 moving the null-check/early return closer to the exec() call so it’s immediately clear that all subsequent uses of
dragin the method depend on it surviving the DnD framework.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider moving the null-check/early return closer to the exec() call so it’s immediately clear that all subsequent uses of `drag` in the method depend on it surviving the DnD framework.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 void DTabBarPrivate::startDrag()
{
// ... existing code ...
Q_EMIT q_func()->dragEnd(action);
// QDrag may be deleted by Qt's DnD framework during exec(),
// causing the QPointer to become null. Early-return to avoid SIGSEGV.
if (!drag)
return;
if (action == Qt::IgnoreAction) {
Q_EMIT q_func()->tabReleaseRequested(d->pressedIndex);
} else if (drag->target() != this) {
// ... existing code ...
}
} |
|
根据堆栈查询到drag为空,目前没复现手段,在此做了规避。 |
|
[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 |
QDrag may be deleted by Qt's DnD framework during exec(), causing the QPointer to become null. Check drag before accessing it after exec() returns to prevent SIGSEGV.
QDrag may be deleted by Qt's DnD framework during exec(), causing
the QPointer to become null. Check drag before accessing it after
exec() returns to prevent SIGSEGV.
Summary by Sourcery
Bug Fixes: