Repository navigation
fix: stub EditWrapper::markdownRenderer in editor_core UT fixture - #674
deepin-bot[bot] merged 1 commit into
Conversation
syncRendererFindHighlight() (introduced in d08b8fe) is called at the end of highlightKeyword()/highlightKeywordInView() and invokes the pure virtual IMarkdownRenderer::highlightSearch() on the pointer returned by m_wrapper->markdownRenderer(). The editor_core fixture never stubbed markdownRenderer(), so the real inline getter ran on the fake wrapper (a reinterpreted QWidget carrier) and returned a garbage non-null pointer, crashing the process with SIGSEGV (exit 139) in: - test_dtextedit_cursor: PrevLine_WithFindBarVisible_HighlightsSyncedKeyword - test_dtextedit_find: ReplaceNext_WithHighlightSelection_ReplacesOnce Stub markdownRenderer() to return nullptr, matching the real EditWrapper default (m_pRenderer = nullptr, early return). Both suites now pass in full (56/56 and 57/57) under QT_QPA_PLATFORM=offscreen.
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe shared editor_core unit-test fixture now stubs EditWrapper::markdownRenderer() to return nullptr, preventing an invalid renderer pointer and virtual call when search-highlight synchronization runs; the affected cursor and find test suites complete successfully. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: [] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例# 当前代码已是正确实现,无需修改。桩函数返回 nullptr 对齐真实 EditWrapper 默认行为: stub.set_lamda(&EditWrapper::markdownRenderer,
[](EditWrapper *) -> IMarkdownRenderer * { return nullptr; });本报告由 AI 代码审查工具自动生成 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, 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 |
|
/merge |
Summary
Fix two SIGSEGV crashes (exit 139) in the editor_core unit tests by stubbing
EditWrapper::markdownRenderer()in the shared test fixture.Problem
syncRendererFindHighlight()(introduced in d08b8fe, search-highlight sync for ReadView) is called at the end ofhighlightKeyword()/highlightKeywordInView()and does:The editor_core fixture uses a fake
EditWrapper(reinterpret_cast<EditWrapper *>over a QWidget carrier) and stubs many of its members — but notmarkdownRenderer(). The real inline getter therefore ran on the QWidget carrier, read a garbage non-null pointer from them_pRendereroffset, and the subsequent virtualhighlightSearch()call dereferenced it, crashing the process:test_dtextedit_cursor:TextEditTest.PrevLine_WithFindBarVisible_HighlightsSyncedKeyword(crash afterScan completed)test_dtextedit_find:TextEditTest.ReplaceNext_WithHighlightSelection_ReplacesOnce(crash afterRendering all selections completed)Both binaries aborted mid-suite, so all subsequent test cases were lost and the CI job finished with exit code 139.
Changes
tests/editor_core/editor_core_fixture.h: stubEditWrapper::markdownRenderer()to returnnullptrininstallWrapperSeams(), matching the realEditWrapperdefault (m_pRenderer = nullptr, early return insyncRendererFindHighlight). Existing assertions are unaffected:m_findMatchSelectionsetc. are populated beforesyncRendererFindHighlight()runs.Testing
CMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ONtest_dtextedit_cursor: 56/56 PASSED (previously exit 139)test_dtextedit_find: 57/57 PASSED (previously exit 139)QT_QPA_PLATFORM=offscreenSummary by Sourcery
Make the editor_core test fixture return no markdown renderer so search-highlight synchronization safely follows the production default.
Bug Fixes:
Tests: