Repository navigation
Conversation
1. Root cause: hideFindWidget() called deleteLater() and set m_findWidget to nullptr, destroying the FindWidget on tab switch; restoreSavedViewState() had no field to save/restore search bar visibility, so switching back showed no search bar 2. Fix: add findWidgetVisible field to SheetOperation, save it in saveCurrentViewState() and restore via handlePrepareSearch() in restoreSavedViewState(); change hideFindWidget() to only hide() without destroying the widget; reorder onTabChanged() to call saveCurrentViewState() before closeFindWidget() 3. Impact: search bar visibility is preserved across tab switches; no behavior change for normal hide/show operations Log: Fixed search bar not restoring after switching document tabs Influence: 1. Test switching tabs with search bar open, verify it restores 2. Test switching tabs with search bar closed, verify no change 3. Test search functionality after multiple tab switches 4. Verify no search state leakage between documents fix: 切换标签页时恢复搜索框状态 1. 根因:hideFindWidget() 调用 deleteLater() 并将 m_findWidget 置空, 切换标签页时销毁了搜索框;restoreSavedViewState() 无搜索框可见性 字段,切回原标签页时搜索框不显示 2. 方案:SheetOperation 添加 findWidgetVisible 字段,saveCurrentViewState() 保存搜索框可见性,restoreSavedViewState() 通过 handlePrepareSearch() 恢复;hideFindWidget() 改为仅 hide() 不销毁;onTabChanged() 调整为 先 saveCurrentViewState() 再 closeFindWidget() 3. 影响:切换标签页后搜索框可见性正确恢复,正常隐藏/显示无行为变化 Log: 修复切换文档标签页后搜索框不恢复的问题 Influence: 1. 测试打开搜索框后切换标签页,验证搜索框恢复 2. 测试关闭搜索框后切换标签页,验证无变化 3. 测试多次切换标签页后搜索功能正常 4. 验证不同文档间搜索状态不串档 PMS: BUG-379133
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: pengfeixx 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 |
Reviewer's GuideThe fix preserves each document tab’s find-widget visibility by saving it before tab-switch cleanup, retaining the widget for reuse, and restoring it when the tab becomes active again without changing normal hide/show behavior. Sequence diagram for restoring find widget state on tab switchsequenceDiagram
participant CentralDocPage
participant PreviousSheet
participant DocSheet
participant SheetBrowser
participant FindWidget
CentralDocPage->>PreviousSheet: saveCurrentViewState()
PreviousSheet->>SheetBrowser: isFindWidgetVisible()
SheetBrowser-->>PreviousSheet: visibility state
PreviousSheet->>PreviousSheet: store findWidgetVisible
CentralDocPage->>PreviousSheet: closeFindWidget()
PreviousSheet->>SheetBrowser: hideFindWidget()
SheetBrowser->>FindWidget: hide()
CentralDocPage->>DocSheet: restoreSavedViewState()
DocSheet->>SheetBrowser: handlePrepareSearch()
SheetBrowser-->>FindWidget: show search widget
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ❌评价: 存在逻辑缺陷 ❌ 不通过 潜在问题: 建议: ['在 SheetBrowser::~SheetBrowser() 中添加 m_findWidget 的清理:if (!m_findWidget.isNull()) { delete m_findWidget; m_findWidget = nullptr; },或将 FindWidget 的父对象改为 this 使其随 SheetBrowser 自动销毁'] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: [] 3. 代码性能 ❌评价: 存在性能问题 ❌ 不通过 潜在问题: 建议: ['为 connect 添加 Qt::UniqueConnection 标志防止重复连接,或将 connect 移入 if (m_findWidget == nullptr) 创建块内仅连接一次'] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// ===== 修复1:SheetBrowser.cpp 析构函数中补充 FindWidget 清理 =====
SheetBrowser::~SheetBrowser()
{
disconnect(this, SIGNAL(sigAddHighLightAnnot(BrowserPage *, QString, QColor)),
this, SLOT(onAddHighLightAnnot(BrowserPage *, QString, QColor)));
qDeleteAll(m_items);
if (nullptr != m_noteEditWidget) {
delete m_noteEditWidget;
}
// 新增:清理 FindWidget,防止因父对象为 window 而泄漏
if (!m_findWidget.isNull()) {
delete m_findWidget;
m_findWidget = nullptr;
}
}
// ===== 修复2:handlePrepareSearch 中使用 Qt::UniqueConnection 防止重复连接 =====
void SheetBrowser::handlePrepareSearch()
{
qCDebug(appLog) << "Preparing search for file type:" << m_sheet->fileType();
if (!Dr::supportsSearch(m_sheet->fileType())) {
qCDebug(appLog) << "Search not supported for current file type";
return;
}
if (m_findWidget == nullptr) {
m_findWidget = new FindWidget(this->window());
int windowY = this->mapTo(this->window(), QPoint(0, 0)).y();
m_findWidget->setYOff(windowY);
m_findWidget->setDocSheet(m_sheet);
qCDebug(appLog) << "Created new FindWidget with Y offset:" << windowY;
}
m_findWidget->updatePosition();
m_findWidget->setSearchEditFocus();
qCDebug(appLog) << "FindWidget positioned and focused";
#ifdef DTKWIDGET_CLASS_DSizeMode
// 使用 Qt::UniqueConnection 防止重复连接
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged,
this, [=](DGuiApplicationHelper::SizeMode sizeMode) {
if (m_findWidget && m_findWidget->isVisible()) {
m_findWidget->updatePosition();
}
}, Qt::UniqueConnection);
#endif
}本报告由 AI 代码审查工具自动生成 |
fix: restore find widget state on tab switch
m_findWidget to nullptr, destroying the FindWidget on tab switch;
restoreSavedViewState() had no field to save/restore search bar
visibility, so switching back showed no search bar
saveCurrentViewState() and restore via handlePrepareSearch() in
restoreSavedViewState(); change hideFindWidget() to only hide()
without destroying the widget; reorder onTabChanged() to call
saveCurrentViewState() before closeFindWidget()
no behavior change for normal hide/show operations
Log: Fixed search bar not restoring after switching document tabs
Influence:
fix: 切换标签页时恢复搜索框状态
切换标签页时销毁了搜索框;restoreSavedViewState() 无搜索框可见性
字段,切回原标签页时搜索框不显示
保存搜索框可见性,restoreSavedViewState() 通过 handlePrepareSearch()
恢复;hideFindWidget() 改为仅 hide() 不销毁;onTabChanged() 调整为
先 saveCurrentViewState() 再 closeFindWidget()
Log: 修复切换文档标签页后搜索框不恢复的问题
Influence:
PMS: BUG-379133
Summary by Sourcery
Restore each document's find widget state across tab switches without changing normal search hide/show behavior.
Bug Fixes:
Enhancements: