diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-06-14 01:01:31 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-06-14 09:50:21 +0200 |
commit | 82ca44ca1a4abb2bcfee5f8ff41df72d02cf4491 (patch) | |
tree | 1795638fbf3ad02c16a69dd69efb8738976f7a07 /tests/auto/qml/qjsvalue/tst_qjsvalue.cpp | |
parent | 6d5a0a55d862c78b185a077171a0b46a94d5a599 (diff) | |
parent | 15b90204fa5126f339db551cf7429534f1359322 (diff) |
Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
tests/auto/qml/qjsengine/tst_qjsengine.cpp
Change-Id: I34df194046a91ee8a076ce28022eb99d68e7f362
Diffstat (limited to 'tests/auto/qml/qjsvalue/tst_qjsvalue.cpp')
-rw-r--r-- | tests/auto/qml/qjsvalue/tst_qjsvalue.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp index a57cd3113c..4de72ae7a1 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp @@ -27,7 +27,14 @@ ****************************************************************************/ #include "tst_qjsvalue.h" + +#include <private/qv4engine_p.h> +#include <private/qjsvalue_p.h> + #include <QtWidgets/QPushButton> +#include <QtCore/qthread.h> + +#include <memory> tst_QJSValue::tst_QJSValue() : engine(nullptr) @@ -2650,4 +2657,34 @@ void tst_QJSValue::nestedObjectToVariant() QCOMPARE(o.toVariant(), expected); } +void tst_QJSValue::deleteFromDifferentThread() +{ +#if !QT_CONFIG(thread) + QSKIP("Need thread support to destroy QJSValues from different threads"); +#else + QV4::PersistentValueStorage storage(engine->handle()); + QCOMPARE(storage.firstPage, nullptr); + QJSValue jsval; + QJSValuePrivate::setRawValue(&jsval, storage.allocate()); + QVERIFY(storage.firstPage != nullptr); + + QMutex mutex; + QWaitCondition condition; + + std::unique_ptr<QThread> thread(QThread::create([&]() { + QMutexLocker locker(&mutex); + QJSValuePrivate::free(&jsval); + QJSValuePrivate::setRawValue(&jsval, nullptr); + QVERIFY(storage.firstPage != nullptr); + condition.wakeOne(); + })); + + QMutexLocker locker(&mutex); + thread->start(); + condition.wait(&mutex); + QTRY_VERIFY(thread->isFinished()); + QTRY_COMPARE(storage.firstPage, nullptr); +#endif +} + QTEST_MAIN(tst_QJSValue) |