Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.5.5, 6.6.3, 6.7.0 Beta2, 6.7
-
6.5.3, 6.6.1
-
Windows 10 22H2, MSVC 2019 x64
-
4d7ce35bd (dev), bc4e1d74e (6.7), 2b3997e29 (6.6), 301cae0a7 (tqtc/lts-6.5)
Description
It looks like the fix for QTBUG-115523 was incomplete. In the test below, only Jane's test produces the expected output - John's test does not.
Code
// test.js function Person(firstName, lastName) { this.firstName = firstName; this.lastName = lastName; } function greet(person) { console.log(`Hello, ${person.firstName} ${person.lastName}!`); } function testJohn() { let john = new Person("John", "Doe"); greet(john); return john; } function testJane() { let jane = { firstName: "Jane", lastName: "Doe" }; greet(jane); return jane; }
// main.cpp int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QFile script(":/test.js"); script.open(QFile::ReadOnly|QFile::Text); QJSEngine engine; engine.installExtensions(QJSEngine::ConsoleExtension); // add console.log() engine.evaluate(script.readAll()); qDebug() << engine.evaluate("testJane()").toVariant(); qDebug() << engine.evaluate("testJohn()").toVariant(); }
Expected output (Qt 6.5.1 and older)
js: Hello, Jane Doe! QVariant(QVariantMap, QMap(("firstName", QVariant(QString, "Jane"))("lastName", QVariant(QString, "Doe")))) js: Hello, John Doe! QVariant(QVariantMap, QMap(("firstName", QVariant(QString, "John"))("lastName", QVariant(QString, "Doe"))))
Actual output (Qt 6.5.3 and newer)
js: Hello, Jane Doe! QVariant(QVariantMap, QMap(("firstName", QVariant(QString, "Jane"))("lastName", QVariant(QString, "Doe")))) js: Hello, John Doe! QVariant(QJSValue, )
Attachments
Issue Links
- relates to
-
QTBUG-115523 [REG: 6.5.1->6.5.2] More complex javascript objects not converted to QVariantMap anymore
- Closed
For Gerrit Dashboard: QTBUG-119963 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
525840,4 | QJSValue: convert more aggressively to QVariant | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
526693,2 | QJSValue: convert more aggressively to QVariant | 6.7 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
526793,2 | QJSValue: convert more aggressively to QVariant | 6.6 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
527005,2 | QJSValue: convert more aggressively to QVariant | tqtc/lts-6.5 | qt/tqtc-qtdeclarative | Status: MERGED | +2 | 0 |