diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2026-09-25 09:50:15 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2026-09-25 13:50:55 +0000 |
| commit | 6dffe5113e04d9eafb26a7ea3e4b41487feb652c (patch) | |
| tree | 1fd08ed26b1d1e5a0d0ede208c88514c122216f0 | |
| parent | 409778c0999ab14d5099eb4703f9efc2c60d781e (diff) | |
tst_qqmlinstantiator: Don't leak memory
The incubator transfers ownership when it's ready. Use std::unique_ptr
to hold on to the object.
Change-Id: I5af2bc517798c0c2a1f88fb2354b0fe71e77f9dd
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
| -rw-r--r-- | tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp b/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp index dbde4de0c6..6bd7fe15e2 100644 --- a/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp +++ b/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp @@ -262,7 +262,8 @@ void tst_qqmlinstantiator::asynchronous() component.create(incubator); while (!incubator.isReady()) incubationController.incubateFor(10); - QQmlInstantiator *instantiator = qobject_cast<QQmlInstantiator *>(incubator.object()); + std::unique_ptr<QObject> root(incubator.object()); + QQmlInstantiator *instantiator = qobject_cast<QQmlInstantiator *>(root.get()); while (incubationController.incubatingObjectCount() > 0) incubationController.incubateFor(10); QVERIFY(instantiator != nullptr); |
