aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktestutils/qml/qmlutils.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2023-10-19 10:05:28 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2023-11-22 22:40:39 +0100
commit7461ae2a946321576f6a495df33e3a17639e246c (patch)
tree9d824d0cff22804097f5e7814df1f391fe501f3b /src/quicktestutils/qml/qmlutils.cpp
parentb9be154316ddd4633ffeab6cbfdbcac847237ba5 (diff)
Prepare tests for upcoming incremental gc
This commit: - Introduces helper functions gcDone and gc. gcDone simply returns true as the gc is currently not incremental. gc is a helper method which has been copied into various tests already, which runs the garbage collections and sends events to clean up objects scheduled for deletion. The new helpers are placed in qmlutils.cpp. - It adds a flag to gc which allows not sending the posted events. That allows using gc in more places, while highlighting the fact that we don't want to process events at this point. This will also help upcoming changes to the incremental gc, which by default will use the event loop to drive the gc processing - It moves some gc calls from QML to C++ – this again will help later to ensure that the gc actually has completed As a driveby, the logging rules early in tst_qv4mm are reset earlier. Task-number: QTBUG-119274 Change-Id: I75d6ffcb3aa459b020e8257155faa91c39653d43 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/quicktestutils/qml/qmlutils.cpp')
-rw-r--r--src/quicktestutils/qml/qmlutils.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/quicktestutils/qml/qmlutils.cpp b/src/quicktestutils/qml/qmlutils.cpp
index 05d94b68ae..6cc54af356 100644
--- a/src/quicktestutils/qml/qmlutils.cpp
+++ b/src/quicktestutils/qml/qmlutils.cpp
@@ -7,6 +7,7 @@
#include <QtCore/QMutexLocker>
#include <QtQml/QQmlComponent>
#include <QtQml/QQmlEngine>
+#include <private/qqmlengine_p.h>
QT_BEGIN_NAMESPACE
@@ -109,6 +110,34 @@ QQmlTestMessageHandler::~QQmlTestMessageHandler()
QQmlTestMessageHandler::m_instance = nullptr;
}
+
+bool gcDone(const QV4::ExecutionEngine *engine) {
+ // always true as long as the gc is non-incremental
+ Q_UNUSED(engine);
+ return true;
+}
+
+void gc(QV4::ExecutionEngine &engine, GCFlags flags)
+{
+ engine.memoryManager->runGC();
+ if (int(GCFlags::DontSendPostedEvents) & int(flags))
+ return;
+ QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+}
+
+bool gcDone(QQmlEngine *engine) {
+ auto priv = QQmlEnginePrivate::get(engine);
+ return gcDone(priv->v4engine());
+}
+
+void gc(QQmlEngine &engine, GCFlags flags)
+{
+ auto priv = QQmlEnginePrivate::get(&engine);
+ gc(*priv->v4engine(), flags);
+}
+
+
QT_END_NAMESPACE
#include "moc_qmlutils_p.cpp"