-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PropertyAnimation: Handle targets being deleted
QQuickPropertyAnimation does not own the targets in its targets list. Thus, we need to be careful to not access deleted objects. Calling QQmlData::wasDeleted is not enoguh, as the object might be fully deleted, but we'd still have a dangling pointer to it. Fix the issue by using QPointer. A similar issue might exists for target, but there we don't normally end up with dangling references - the engine will correctly null the target. And the QPointer isNull check will avoid potentiall nullptr derefences there, too. Ideally, we would use QQmlGuard instead of QPointer, as it would have a lower overhead - however, we run into linker issues on MSVC. Fixing them is deferred to a future commit, to not block this crash fix. Fixes: QTBUG-100392 Pick-to: 6.5 6.6 6.2 Change-Id: If084e2e0f22d50dbee8bf5aedfa2e749e79fc105 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
- Loading branch information
Showing
4 changed files
with
90 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
tests/auto/quick/qquickanimations/data/targetsDeletedWithoutRemoval.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import QtQuick | ||
|
||
Item { | ||
id: root | ||
|
||
property list<Translate> targets | ||
property alias animTargets: animation.targets | ||
|
||
Component { | ||
id: trComponent | ||
Translate {} | ||
} | ||
|
||
Component.onCompleted: { | ||
const target = trComponent.createObject(this); | ||
targets.push(target); | ||
target.destroy(); | ||
// give event loop some time to actually stop the animation and destroy the target | ||
Qt.callLater(animation.start); | ||
} | ||
|
||
NumberAnimation { | ||
id: animation | ||
targets: root.targets | ||
property: "x" | ||
running: false | ||
to: 100 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters