Details
-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
5.12.5
Description
When I am trying to dump (console.log) array that is came to JS from C++ I see flattening array even if there array inside of array, but when I am doing "foreach" it's OK.
JS:
console.log("list:",CPPDeclaredObject.mList()); var oList = CPPDeclaredObject.mList(); for (var i = 0; i < oList.length; i++) { console.log("line",i,":",oList[i]); }
C++
QList<QVariant> CPPDeclaredObject::mList(void) { QList<QVariant> oOutput = {}; int iCounter = 0; for ( QHash<QString,CPPDeclaredObjectPrimitive*>::iterator i = pObjects.begin(); i != pObjects.end(); ++i ) { QList<QVariant> iObject = {}; iObject.append(i.value()->pName); iObject.append(i.value()->pDescription); oOutput.insert(iCounter,iObject); ++iCounter; } return oOutput; }
Console output from JS console.log():
qml: list: [test 1 name,test 111111 description,test 2 name,test 22222222222222 description,QML_name2,QML_description,QML_name1,QML_description] qml: line 0 : [test 1 name,test 111111 description] qml: line 1 : [test 2 name,test 22222222222222 description] qml: line 2 : [QML_name2,QML_description] qml: line 3 : [QML_name1,QML_description]
Sometimes it's making debug very complicated.