[Qt5-feedback] Qt5 and C++ exception
Thiago Macieira
thiago at kde.org
Wed Jun 29 11:39:31 CEST 2011
Em Wednesday, 29 de June de 2011, às 11:08:52, Stephen Bryant escreveu:
> That's OK, but you need to ensure that non-exception based error
> handling actually exists.
>
> A number of the template collection methods return void instead of
> reporting failure - such as resize(), push_back() et al. I'm guessing
> the API was copied from STL, but those explicitly use exceptions.
Those are expected never to fail. Qt doesn't handle OOM gracefully.
The containers have been tested to properly let a std::bad_alloc go through
though. If new or the type's constructor throws, the container will let the
exception through.
> Maybe Qt5 could return a bool to denote success/failure? If one ignores
> the return value, the behaviour would be the same as in Qt4.
Not for OOM situations, except for APIs that are expected to allocate large
amounts of memory (like QImage and QPixmap).
> The documentation should probably be updated to explicitly say that Qt
> does not catch any exceptions thrown by new. Actually, the current
> class docs don't seem to say anything about handling failure.
Right, they don't catch. The exception is let through and we try to do some
cleanup on the catch, then rethrow. But this is implementation behaviour.
We haven't finished getting the containers to be exception-safe, so we don't
promise it either.
Try not to run out of memory.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt.nokia.com/pipermail/qt5-feedback/attachments/20110629/afe8d85f/attachment.bin
More information about the Qt5-feedback
mailing list