fix: reset m_fIsDeleting on cancel by listening to DFDeleteDialog::re…#196
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideConnects the delete confirmation dialog's rejected signal directly to the cancel handler so the deletion state flag is always reset when the user cancels, preventing the dialog from failing to appear on subsequent delete attempts. Sequence diagram for delete dialog cancel path fixsequenceDiagram
actor User
participant DFontMgrMainWindow
participant DFDeleteDialog
User->>DFontMgrMainWindow: delCurrentFont(activatedByRightmenu)
DFontMgrMainWindow->>DFDeleteDialog: new DFDeleteDialog(...)
DFontMgrMainWindow->>DFDeleteDialog: connect(accepted, onconfirmDelDlgAccept)
DFontMgrMainWindow->>DFDeleteDialog: connect(rejected, cancelDelete)
User->>DFDeleteDialog: reject()
DFDeleteDialog-->>DFontMgrMainWindow: rejected
DFontMgrMainWindow->>DFontMgrMainWindow: cancelDelete()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
…jected log: Pressing Cancel on the delete-confirmation dialog triggers reject() + close() on an already-hidden dialog, on which DDialog::closed is not reliably emitted. As a result cancelDelete() was never called and m_fIsDeleting stayed at Deleting, so the next call to delCurrentFont() was blocked at the entry gate 'if (m_fIsDeleting > UnDeleting) return;', making the confirmation dialog fail to appear on every subsequent right-click delete. Connect DFDeleteDialog::rejected directly to cancelDelete() so the delete state flag is always reset on the cancel path. pms: bug-347229
deepin pr auto review你好!我是CodeGeeX,很高兴为你进行代码审查。 针对你提供的 Git Diff,本次修改非常简单:在删除字体时弹出的确认对话框中,新增了对 虽然修改意图明确,但在语法逻辑、代码质量、代码性能和代码安全方面,我有以下审查意见和改进建议: 1. 语法与逻辑
2. 代码质量
3. 代码性能
4. 代码安全
💡 综合改进后的代码建议结合以上分析,建议对这段代码进行如下微调,以确保代码的健壮性和无内存泄漏: void DFontMgrMainWindow::delCurrentFont(bool activatedByRightmenu)
{
DFDeleteDialog *confirmDelDlg = new DFDeleteDialog(this, m_menuDelCnt, m_menuSysCnt, m_menuCurCnt > 0, this);
// 设置对话框关闭时自动销毁,防止内存泄漏
confirmDelDlg->setAttribute(Qt::WA_DeleteOnClose);
connect(confirmDelDlg, &DFDeleteDialog::accepted, this, &DFFontMgrMainWindow::onconfirmDelDlgAccept);
connect(confirmDelDlg, &DFDeleteDialog::rejected, this, &DFontMgrMainWindow::cancelDelete);
confirmDelDlg->move(this->geometry().center() - confirmDelDlg->rect().center());
// 建议使用 exec() 模态显示(如果原本就是 exec,则忽略此条)
// 或者如果是非模态 show(),确保主窗口在对话框存在期间的交互是安全的
confirmDelDlg->show();
}补充检查清单(请对照你的
|
| DFDeleteDialog *confirmDelDlg = new DFDeleteDialog(this, m_menuDelCnt, m_menuSysCnt, m_menuCurCnt > 0, this); | ||
|
|
||
| connect(confirmDelDlg, &DFDeleteDialog::accepted, this, &DFontMgrMainWindow::onconfirmDelDlgAccept); | ||
| connect(confirmDelDlg, &DFDeleteDialog::rejected, this, &DFontMgrMainWindow::cancelDelete); |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: JWWTSL, lzwind 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 |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
log: Pressing Cancel on the delete-confirmation dialog triggers reject() + close() on an already-hidden dialog, on which DDialog::closed is not reliably emitted. As a result cancelDelete() was never called and m_fIsDeleting stayed at Deleting, so the next call to delCurrentFont() was blocked at the entry gate
if (m_fIsDeleting > UnDeleting) return;, making the confirmation dialog fail to appear on every subsequent right-click delete.Connect DFDeleteDialog::rejected directly to cancelDelete() so the delete state flag is always reset on the cancel path.
pms: bug-347229
Summary by Sourcery
Bug Fixes: