fix(test): connect sheet destroyed signal to prevent singleton segfault - #376
Conversation
UT_onTaskFinished and UT_addgetDocImageTask registered DocSheet pointers with the ReaderImageThreadPoolManager singleton but did not connect the sheet's destroyed() signal to onDocProxyDestroyed for cleanup, unlike UT_setImageForDocSheet which already had this connection. When the tests deleted their DocSheet objects, dangling pointers remained in the singleton's internal map. At program exit the singleton destructor accessed these dangling pointers, causing a segmentation fault (exit 255). Add the missing QObject::connect(sheet, &QObject::destroyed, m_tester, &ReaderImageThreadPoolManager::onDocProxyDestroyed) to both tests so the singleton properly cleans up when the sheet is destroyed.
There was a problem hiding this comment.
Sorry @pengfeixx, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 19 hours by commenting @sourcery-ai review. Upgrade to get a review now.
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFixes a test shutdown SIGSEGV by matching the existing destroyed-signal cleanup pattern in both affected test cases, preventing ReaderImageThreadPoolManager from retaining deleted DocSheet pointers. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[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 |
问题
test-deepin-reader在运行完最后一个用例UT_ReaderImageThreadPoolManager.UT_addgetDocImageTask后,进程退出阶段发生段错误(SIGSEGV,exit code 255)。根因
UT_onTaskFinished和UT_addgetDocImageTask两个用例创建了DocSheet对象并注册到ReaderImageThreadPoolManager单例中,但在删除 sheet 时未连接destroyed信号到onDocProxyDestroyed槽进行清理(同文件中UT_setImageForDocSheet有此连接且正常通过)。sheet 被
delete后,单例内部仍持有悬空指针,进程退出时单例析构访问这些悬空指针 → 段错误。修复
在
UT_onTaskFinished和UT_addgetDocImageTask中,于调用onTaskFinished/addgetDocImageTask之前添加:QObject::connect(sheet, &QObject::destroyed, m_tester, &ReaderImageThreadPoolManager::onDocProxyDestroyed);与
UT_setImageForDocSheet保持一致,确保 sheet 销毁时单例正确清理内部引用。验证
UT_ReaderImageThreadPoolManager全部 9 个用例通过变更文件
tests/sidebar/ut_readerimagethreadpoolmanager.cpp(+4 行)Summary by Sourcery
Prevent dangling document-sheet references from causing singleton teardown segmentation faults in image thread pool manager tests.
Bug Fixes:
Tests: