|
|
Hi,
Hmm, yes, I didn't look sharp enough, sorry. One of the ids has to be the
default id, which is all '0', and the other a random one created with
QUuid::makeUuid() (in your test both are default). Or one has to be a
custom id like 0000000000000000000000001 or 000000000000000000002. Thus
having a default id and/or any custom ids and else regular random ids map
will assume that they are all equal to the default id or one of the custom
ids and never insert any of the random ids.
I can reproduce that now:
#include <QUuid>
#include <QDebug>
int main() {
QUuid uuid1;
QUuid uuid2 = QUuid::createUuid();
switch (uuid1.variant()) {
case QUuid::VarUnknown: qDebug() << "uuid1: Unknown"; break;
case QUuid::DCE: qDebug() << "uuid1: DCE"; break;
default: break;
}
switch (uuid2.variant()) {
case QUuid::VarUnknown: qDebug() << "uuid2: Unknown"; break;
case QUuid::DCE: qDebug() << "uuid2: DCE"; break;
default: break;
}
qDebug() << "uuid1 > uuid2: " << ((uuid1 > uuid2) ? "true" : "false");
qDebug() << "uuid1 < uuid2: " << ((uuid1 < uuid2) ? "true" : "false");
qDebug() << "uuid1 != uuid2:" << ((uuid1 != uuid2) ? "true" : "false");
}
This is documented behaviour, see operator> for QUuid. It says there
that the 2 QUuids need to be of the same variant and are then compared
lexicographically. In the docs for variant() it clearly states that the
null Uuid (the default value) is of unkown variant.
That's indeed documented behavior:
http://doc.trolltech.com/4.1/quuid.html#operator-gt
That said, the documented behavior is not necessarily a good idea since
it breaks QMap. Unfortunately this can't be changed in the Qt 4.1 series
without seriously breaking compatibility. I still suggest you send a bug
report to Trolltech, explaining that you have read the documentation but
that the documented behavior breaks QMap:
http://www.trolltech.com/forms/feedbackform.html
--
Dimitri
--
To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
"unsubscribe" in the subject or the body.
List archive and information: http://lists.trolltech.com/qt-interest/
|
|