[Qt-interest] Qt Containers (or: why I must use STL)
Stephen Bryant
steve at bawue.de
Mon Oct 12 23:36:43 CEST 2009
Hello everybody!
Am I the only person to have run into this?
If I add items to a container, there is no way to tell if it failed.
Given that Qt doesn't throw exceptions, and the methods return void,
does anybody know how to do this? I tried resizing up and up to see
what happens, and the whole program hung.
Actually, it's worse than that: the reserve() and resize() methods
take a signed int. Signed? That's just plain silly!
On x86_64, int is still only 4 bytes, so despite masses
of memory, I can never have a byte array larger than 2GB.
I know how I'd like to fix it, but I suspect it may not be possible
without breaking binary compatibility - at least on 32-bit. Where
we now have methods such as this:
void QVector::resize ( int size );
I would add this (and mark the other as deprecated):
bool QVector::resize ( const size_t size );
I didn't enter a bug report for this. I found one already: 132094
(QVector crashes when allocation fails). It was rejected with the
following reason: Qt doesn't handle out-of-memory scenarios cleanly.
Is that a joke? It doesn't handle them at all! That in itself is
quite a major bug.
Does anybody have any other solutions? Perhaps somebody from Nokia
would care to comment. For now, I'm using Qt with STL containers. :-)
Steve
More information about the Qt-interest-old
mailing list