Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.2.1
-
None
-
Windows 7, Mac OS 10.8
-
7b3eb5373a0d3611c5a83379c5eb59505cc5c074 (qtdeclarative)
Description
Using Array.prototype.forEach() on a Qt list does not give stable result.
The following test passes with a success rate of about 95% on Windows 7, but fails randomly. If I replace forEach with a for loop, it always passes.
import QtQuick 2.2 import QtTest 1.0 Item { Column { id: column Text { text: "1" } Text { text: "2" } Text { text: "3" } } TestCase { name: "ArrayPrototypeForEachOnList" function test_forEach() { var count = 0; Array.prototype.forEach.call(column.children, function(child) { ++count; }); compare(count, 3); } } }
In addition, there also seem to be platform differences. While the test above runs fine on Mac OS, the following program always logs "count: 0" to the console when I click into its window on Mac OS, whereas it correctly logs "count: 3" Windows:
import QtQuick 2.0 Rectangle { width: 360 height: 360 Column { id: item Text { text: "Hello World 1" } Text { text: "Hello World 2" } Text { text: "Hello World 3" } } MouseArea { anchors.fill: parent onClicked: { var count = 0; Array.prototype.forEach.call(item.children, function(child) { ++count; }); console.log("count:" + count); } } }