fix: remove source model destroyed handler to prevent crash#1470
fix: remove source model destroyed handler to prevent crash#1470deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
Conversation
There was a problem hiding this comment.
Sorry @18202781743, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia 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 |
Removed the connection to the source model's destroyed signal that was causing a crash during abnormal exit. The handler was attempting to reset the model while it was already being updated, leading to invalid state access and crashes. This connection was unnecessary as the source model cleanup is already handled by Qt's parent-child relationship. ``` #0 0x00007f72b49dabe6 in QAbstractProxyModel::canFetchMore (this=0x55c861a82510, parent=...) at ./src/corelib/itemmodels/qabstractproxymodel.cpp:413 #1 0x00007f72b3cb4de6 in ??? () at /lib/x86_64-linux-gnu/libQt6QmlModels.so.6 #2 0x00007f72b3cc74c0 in QQmlDelegateModel::handleModelReset() () at /lib/x86_64-linux-gnu/libQt6QmlModels.so.6 #3 0x00007f72b486246c in QtPrivate::QSlotObjectBase::call (a=0x7ffeda7ec110, r=0x55c862f7a070, this=0x55c862f80fe0, this=<optimized out>, r=<optimized out>, a=<optimized out>) at ./src/corelib/kernel/qobjectdefs_impl.h:486 #4 doActivate<false> (sender=0x55c861a82510, signal_index=21, argv=0x7ffeda7ec110) at ./src/corelib/kernel/qobject.cpp:4120 #5 0x00007f72b49cb2e1 in QAbstractItemModel::modelReset (this=<optimized out>, _t1=...) at ./obj-x86_64-linux-gnu/src/corelib/Core_autogen/include/moc_qabstractitemmodel.cpp:1113 #6 0x00007f729fdb0be3 in operator() (__closure=0x55c861b48b40) at /home/work/dde-shell/panels/dock/taskmanager/dockitemmodel.cpp:89 #7 0x00007f729fdb284b in operator() (__closure=0x7ffeda7ec1b0) at /usr/include/x86_64-linux-gnu/qt6/QtCore/qobjectdefs_impl.h:141 #8 0x00007f729fdb2944 in QtPrivate::FunctorCallBase::call_internal<void, QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, dock::DockItemModel::setSourceModel(QAbstractItemModel*)::<lambda()> >::call(dock::DockItemModel::setSourceModel(QAbstractItemModel*)::<lambda()>&, void**)::<lambda()> >(void **, struct {...} &&) (args=0x7ffeda7ec340, fn=...) at /usr/include/x86_64-linux-gnu/qt6/QtCore/qobjectdefs_impl.h:65 #9 0x00007f729fdb2881 in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, dock::DockItemModel::setSourceModel(QAbstractItemModel*)::<lambda()> >::call(struct {...} &, void **) (f=..., arg=0x7ffeda7ec340) at /usr/include/x86_64-linux-gnu/qt6/QtCore/qobjectdefs_impl.h:140 #10 0x00007f729fdb2633 in QtPrivate::FunctorCallable<dock::DockItemModel::setSourceModel(QAbstractItemModel*)::<lambda()> >::call<QtPrivate::List<>, void>(struct {...} &, void *, void **) (f=..., arg=0x7ffeda7ec340) at /usr/include/x86_64-linux-gnu/qt6/QtCore/qobjectdefs_impl.h:362 #11 0x00007f729fdb250a in QtPrivate::QCallableObject<dock::DockItemModel::setSourceModel(QAbstractItemModel*)::<lambda()>, QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void **, bool *) (which=1, this_=0x55c861b48b30, r=0x55c861a82510, a=0x7ffeda7ec340, ret=0x0) at /usr/include/x86_64-linux-gnu/qt6/QtCore/qobjectdefs_impl.h:572 #12 0x00007f72b486246c in QtPrivate::QSlotObjectBase::call (a=0x7ffeda7ec340, r=0x55c861a82510, this=0x55c861b48b30, this=<optimized out>, r=<optimized out>, a=<optimized out>) at ./src/corelib/kernel/qobjectdefs_impl.h:486 #13 doActivate<false> (sender=0x55c861afbfc0, signal_index=0, argv=0x7ffeda7ec340) at ./src/corelib/kernel/qobject.cpp:4120 #14 0x00007f72b48629c3 in QObject::destroyed (this=<optimized out>, _t1=<optimized out>) at ./obj-x86_64-linux-gnu/src/corelib/kernel/moc_qobject.cpp:229 ``` Influence: 1. Test application exit scenarios to ensure no crashes occur 2. Verify dock item model updates correctly during normal operation 3. Test with multiple source model changes and updates 4. Verify model reset functionality still works properly when needed fix: 移除源模型销毁处理程序以防止崩溃 移除了导致异常退出时崩溃的源模型销毁信号连接。该处理程序在模型已处于更新 状态时尝试重置模型,导致无效状态访问和崩溃。此连接是不必要的,因为源模型 的清理已由Qt的父子关系处理。 Influence: 1. 测试应用程序退出场景,确保不会发生崩溃 2. 验证在正常操作期间dock项目模型是否正确更新 3. 测试多个源模型更改和更新 4. 验证模型重置功能在需要时仍能正常工作
deepin pr auto review这段代码主要进行了两处修改:更新了版权年份,并删除了源模型销毁时的处理逻辑。以下是对这两处修改的审查意见: 1. 版权年份更新修改内容:将版权年份从 审查意见:
2. 删除源模型销毁的连接逻辑修改内容:删除了 审查意见:
改进建议强烈建议恢复或重写关于 推荐的改进代码方案: // 在 setSourceModel 中或其他合适位置
connect(sourceModel(), &QAbstractItemModel::destroyed, this, [this]() {
// 1. 防止重入
if (m_isUpdating)
return;
// 2. 通知视图模型即将重置,视图应停止访问数据
beginResetModel();
// 3. 【关键】显式处理源模型指针,防止后续访问野指针
// 注意:这取决于 DockItemModel 的具体实现,通常需要确保 sourceModel() 返回 nullptr
// 或者内部逻辑在 sourceModel 为空时能安全返回(例如 rowCount 返回 0)
// 假设类中有成员变量 m_sourceModel 或者通过 QAbstractProxyModel 机制管理
// 如果没有显式置空机制,这里至少保证了 beginResetModel 被调用
endResetModel();
});补充说明: 总结: |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Removed the connection to the source model's destroyed signal that was
causing a crash during abnormal exit. The handler was attempting to
reset the model while it was already being updated, leading to invalid
state access and crashes. This connection was unnecessary as the source
model cleanup is already handled by Qt's parent-child relationship.
Influence:
fix: 移除源模型销毁处理程序以防止崩溃
移除了导致异常退出时崩溃的源模型销毁信号连接。该处理程序在模型已处于更新
状态时尝试重置模型,导致无效状态访问和崩溃。此连接是不必要的,因为源模型
的清理已由Qt的父子关系处理。
Influence: