Conversation
isFullScreen()/openFullScreen()/quitFullScreen()/onSheetCountChanged() called parentWidget()->parentWidget()->parentWidget() unchecked; if the widget has fewer than three levels of parents (embedded use, tests) the chain dereferences a null QWidget and crashes. The existing null check only covered the final dynamic_cast result. Replace the chained calls with a parentMainWindow() helper that stops at the first null level. Log: Influence: doc page fullscreen handling
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos 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 guide (collapsed on small PRs)Reviewer's GuideCentralDocPage now resolves its owning MainWindow through a null-safe helper, preventing crashes when embedded or test widget hierarchies do not contain the expected three parent levels. All four affected call sites use the shared lookup. Sequence diagram for null-safe MainWindow lookupsequenceDiagram
participant Caller
participant CentralDocPage
participant parentMainWindow
participant QWidget
participant MainWindow
Caller->>CentralDocPage: isFullScreen()
CentralDocPage->>parentMainWindow: parentMainWindow(this)
loop Up to 3 levels while widget != nullptr
parentMainWindow->>QWidget: parentWidget()
QWidget-->>parentMainWindow: parent widget or nullptr
end
alt MainWindow found
parentMainWindow->>MainWindow: isFullScreen()
MainWindow-->>CentralDocPage: fullscreen state
else Parent chain ends early or type mismatch
parentMainWindow-->>CentralDocPage: nullptr
CentralDocPage-->>Caller: false or return
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
CentralDocPage的isFullScreen()/openFullScreen()/quitFullScreen()/onSheetCountChanged()(reader/uiframe/CentralDocPage.cpp :897/:908/:928/:976)均使用parentWidget()->parentWidget()->parentWidget()三级父链。parentWidget()非虚且内部解引用 d 指针,任一级为空(嵌入场景/测试环境父链不足三级)即对空指针调用崩溃——末尾的if (nullptr == mainWindow)只能拦截第三级为空的情况。gdb 实测:setSidebarVisible(issue 164325 修复路径)触发 SIGSEGV atQWidget::parentWidget(this=0x0)。同文件 :976 的调用点之后用了mainWindow && ...判空,说明防护模式已知但未一致应用。修复
新增文件内静态辅助
parentMainWindow(CentralDocPage *):逐级向上取父并随时判空,最后再做dynamic_cast;4 处调用点统一替换。背景
该问题由 AI 辅助单测(PMS 缺陷热点回归,BUG164325 用例运行时 gdb 定位)发现。
Summary by Sourcery
Safely traverse CentralDocPage’s parent hierarchy before accessing the parent MainWindow.
Bug Fixes: