Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.2.4, 6.3.1
-
Win 10 Pro 64bit 10.0.19044, Build 19044. Qt 6.3.1. Compiler MSVC2019 16.6.30225.117 amd64
-
-
c8e756e560ce3f0d369df65986e5578e0e963c66 fa8dc8c40b (qt/tqtc-qtdeclarative/6.2) 7eb012ebd9 (qt/qtdeclarative/6.3)
Description
Both in release and debug mode, if the Quick Compiler is enabled, the invocation of the function has no effect. If the Quick compiler is disabled, it works. If we add a console.log('') call inside the function, the function has effect again. Probably, after the translation from js to cpp, the cpp code gets compiled in a way that the call is optimized away. Inserting the line console.log('') prevents the translation to cpp primitives and so the function is correctly invoked
// main.cpp #include <QGuiApplication> #include <QQmlApplicationEngine> #include <QTimer> #include <QQmlComponent> #include <QWindow>int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; const QUrl url(QStringLiteral("qrc:/main.qml")); QQmlComponent component(&engine, url); QWindow *window = qobject_cast<QWindow*>(component.create()); QTimer::singleShot(2000, window, [window](){ QMetaObject::invokeMethod(window, "movePoint", Q_ARG(QPointF, QPointF(200, 200))); }); return app.exec(); } //main.qml import QtQuick import QtQuick.Window Window { width: 640 height: 480 visible: true title: qsTr("Hello World") function movePoint(position: point) { test.x = position.x test.y = position.y } Rectangle { id: test width: 200 height: 200 color: "green" } }