[Interest] Strange bug in QML shift() & sort() functions.

Alexandre BERAUD aberaud at infflux.com
Tue Oct 18 14:48:32 CEST 2016


Dear trolls,

I have recently run into something very close to a bug in the QML JavaScript engine of Qt 5.7.

It looks like, when you have an array of objects and then you shift() and push() elements of that array, sorting becomes erratic.

Example with a simple QML file :

import QtQuick 2.0

Item {
                id: main_win

                width: 800
                height: 600

                Component.onCompleted: {
var l = [1,2,3,4,5,6,7,8,9];
for (var k = 0; k < 10; k++) {
l.sort(function(a,b) {return a-b;});
console.log(l);
l.shift();
l.push(9);
}
                }
}

The output is :
qml: [1,2,3,4,5,6,7,8,9]
qml: [3,4,5,6,7,8,9,9,2]
qml: [5,6,7,8,9,9,9,2,4]
qml: [7,8,9,9,9,9,2,4,6]
qml: [9,9,9,9,9,2,4,6,8]
qml: [9,9,9,9,2,4,6,8,9]
qml: [9,9,9,2,4,6,8,9,9]
qml: [9,9,2,4,6,8,9,9,9]
qml: [9,2,4,6,8,9,9,9,9]
qml: [2,4,6,8,9,9,9,9,9]

Note that the same test with QScriptEngine give the expected result.

Does anyone already know of that issue ? Do you think I should create a bug report ?

Regards,
___________________________________
Alexandre BERAUD
Responsable du Service Développement
[INFFLUX-VOLUME_MARRON-Monochrome-Groupe-CFD-SignatureMail]<http://www.infflux.com/>
197, rue de Fontenay
F-94300 Vincennes
Tel : +33 (0)1 49 57 92 00
email :aberaud at infflux.com<mailto:aberaud at infflux.com>
Nos actualités en exclusivité sur...
[Logo Linkedin.png]<https://www.linkedin.com/company/infflux> [Logo Twitter.png] <https://twitter.com/INFFLUX>  [Logo Facebook.png] <https://www.facebook.com/Infflux-387529587939147/>
[ban_sce2016_STAND_INFFLUX_C48_600x135px]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20161018/92d23d7e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image011.png
Type: image/png
Size: 4669 bytes
Desc: image011.png
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20161018/92d23d7e/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image012.png
Type: image/png
Size: 2372 bytes
Desc: image012.png
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20161018/92d23d7e/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image013.png
Type: image/png
Size: 2428 bytes
Desc: image013.png
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20161018/92d23d7e/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image014.png
Type: image/png
Size: 2013 bytes
Desc: image014.png
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20161018/92d23d7e/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image015.png
Type: image/png
Size: 111148 bytes
Desc: image015.png
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20161018/92d23d7e/attachment-0004.png>


More information about the Interest mailing list