[Interest] QStringList, takeFirst and order of execution

Samuel Gaist samuel.gaist at edeltech.ch
Mon Nov 11 13:37:20 CET 2013


Hi,

I have been experiencing a strange behavior with QStringList and the order of execution of takeFirst.

The following code:

QString line = file.readLine();  // line contains "46 71\n"
QStringList lineData = line.split(); // lineData contains ("46", "71\n")
qDebug() << lineData.takeFirst() << lineData.takeFirst();

behaves differently on two computers.

The first one is a MacOS X 10.8.5 with Xcode 4.6.3 installed and using the 5.2.0 alpha package with gcc
The second one is a MacOS X 10.8.5 with Xcode 5.0.1 installed and a developer build (no special configuration) of the latest stable branches from git with clang

The first computer outputs "71\n" "46" and the second one "46" "71\n"

The same happens if I build e.g. a QSize using:

QSize mySize = QSize(lineData.takeFirst().toInt(), lineData.takeFirst().toInt());

on the other hand, if I call 

qDebug() << lineData.takeFirst();
qDebug() << lineData.takeFirst();

The order is correct on both of them. 

What could explain the difference ?


More information about the Interest mailing list