Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.3.0
-
None
-
Windows 7
-
3dbe05f6bf3fd51ce8097c35f6c7f12b39acb0f6 (qtdeclarative)
Description
A property alias on a JavaScript object does not point to the same object. In fact, it points to an object of which the functions have been turned into objects that cannot be invoked.
This also happens when you assign a JavaScript object to an alias, in which case both the alias and the aliased property have their functions turned into non-invokable objects.
Here is a test to illustrate the problem (with working code for an alias on a QML item for comparison):
import QtQuick 2.3 import QtTest 1.0 Item { QtObject { id: myObject property var item: Item {} property alias itemAlias : myObject.item property var jsObject: ({ myFunction: function(x,y) {} }) property alias jsObjectAlias : myObject.jsObject } TestCase { function test_itemAlias() { // this works compare(myObject.itemAlias, myObject.item); compare(typeof(myObject.itemAlias.childAt), typeof(myObject.item.childAt)); } function test_jsObjectAlias() { // the following comparison fails compare(myObject.jsObjectAlias, myObject.jsObject); // the following comparison also fails (actual: object; expected: function) compare(typeof(myObject.jsObjectAlias.myFunction), typeof(myObject.jsObject.myFunction)); } function test_jsObjectAliasAssignment() { var myJsObject = { myOtherFunction: function(x,y) {} }; myObject.jsObjectAlias = myJsObject; // the following comparisons fails compare(myObject.jsObject, myJsObject); compare(myObject.jsObjectAlias, myJsObject); // the following comparisons also fails (actual: object; expected: function) compare(typeof(myObject.jsObject.myOtherFunction), typeof(myJsObject.myOtherFunction)); compare(typeof(myObject.jsObjectAlias.myOtherFunction), typeof(myJsObject.myOtherFunction)); } } }
Attachments
Issue Links
- relates to
-
QTBUG-38470 QVariantMap contents converted when passing from C++ to qml.
- Closed
-
QTBUG-33815 Copying JavaScript object to QVariant breaks functions
- Closed
For Gerrit Dashboard: QTBUG-40431 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
94438,6 | Fix mapping of JS objects/arrays to C++ | 5.4 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
95263,2 | Fix compiler warnings in qv8engine.cpp. | 5.4 | qt/qtdeclarative | Status: MERGED | +2 | 0 |