-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: accessing wild pointer in qt6 #296
Conversation
qobject_cast<QWindow*>(window) is returned nullptr if window is destroyed in qt6, and we can see it on tst_QWindow::qobject_castOnDestruction() in tst_qwindow.cpp. Object's address may be the same as before in qt6, memory may be optimized. pms: BUG-299239
deepin pr auto review代码审查意见:
|
Synchronize source files from linuxdeepin/dtkgui. Source-pull-request: linuxdeepin/dtkgui#296
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QObject::destroyed后代表该对象即将被真正销毁,对象的状态不稳定,操作对象可能会导致一些无法预测的错误(qobject_cast类型安全检查无法通过,即转换为nullptr)且这里不需要再使用该对象,仅移除对象在QList中存储的的指针,所以使用static_cast进行强制类型转换
我这样理解对吗,如果ok,改动合理
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, mhduiy The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
不过为什么强调仅在Qt6下会出现这样的情况 |
Synchronize source files from linuxdeepin/dtkgui. Source-pull-request: linuxdeepin/dtkgui#296
qobject_cast<QWindow*>(window) is returned nullptr if window is destroyed in qt6, and we can see it on tst_QWindow::qobject_castOnDestruction() in tst_qwindow.cpp.
Object's address may be the same as before in qt6, memory may be optimized.
pms: BUG-299239