Skip to content

Commit

Permalink
tst_QObject: don't leak QtDeclarative::theData
Browse files Browse the repository at this point in the history
Pick-to: 6.8
Change-Id: I347f7558a3b278590b11fffdc48877791c29ca60
Reviewed-by: Volker Hilsheimer <[email protected]>
  • Loading branch information
thiagomacieira committed Nov 6, 2024
1 parent 7944ee7 commit ee3933a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tests/auto/corelib/kernel/qobject/tst_qobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8646,25 +8646,25 @@ class SenderWithSharedPointerConstQObject : public QObject
correctly guarded. QTBUG-105286
*/
namespace QtDeclarative {
static QAbstractDeclarativeData *theData;
static std::unique_ptr<QAbstractDeclarativeData> theData;

static void destroyed(QAbstractDeclarativeData *data, QObject *)
{
QCOMPARE(data, theData);
QCOMPARE(data, theData.get());
}
static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
{
QCOMPARE(data, theData);
QCOMPARE(data, theData.get());
}
// we can't use QCOMPARE in the next two functions, as they don't return void
static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
{
QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
QTest::qCompare(data, theData.get(), "data", "theData", __FILE__, __LINE__);
return 0;
}
static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
{
QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
QTest::qCompare(data, theData.get(), "data", "theData", __FILE__, __LINE__);
return true;
}

Expand Down Expand Up @@ -8705,7 +8705,8 @@ void tst_QObject::declarativeData()

QtDeclarative::Object p;
QObjectPrivate *priv = QObjectPrivate::get(&p);
priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
priv->declarativeData = new QAbstractDeclarativeData;
QtDeclarative::theData.reset(priv->declarativeData);

connect(&p, &QtDeclarative::Object::theSignal, &p, []{
});
Expand Down

0 comments on commit ee3933a

Please sign in to comment.