Skip to content

Commit

Permalink
fix: accessing wild pointer in qt6
Browse files Browse the repository at this point in the history
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
  • Loading branch information
18202781743 committed Jan 9, 2025
1 parent 1ede364 commit 7362e04
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ MoveWindowHelper::MoveWindowHelper(QWindow *window)

MoveWindowHelper::~MoveWindowHelper()
{
mapped.remove(qobject_cast<QWindow*>(parent()));
mapped.remove(static_cast<QWindow*>(parent()));
}

void MoveWindowHelper::updateEnableSystemMoveFromProperty()
Expand Down Expand Up @@ -178,7 +178,8 @@ DTreeLandPlatformWindowHelper::DTreeLandPlatformWindowHelper(QWindow *window)

DTreeLandPlatformWindowHelper::~DTreeLandPlatformWindowHelper()
{
windowMap.remove(window());
// see tst_qwindow.cpp tst_QWindow::qobject_castOnDestruction()
windowMap.remove(static_cast<QWindow*>(parent()));
}

bool DTreeLandPlatformWindowHelper::eventFilter(QObject *watched, QEvent *event) {
Expand Down

0 comments on commit 7362e04

Please sign in to comment.