[Interest] App. is running after an exception is thrown.

Thiago Macieira thiago.macieira at intel.com
Sat Jul 27 18:04:53 CEST 2013


On sábado, 27 de julho de 2013 15:09:24, Alexander Syvak wrote:
> > Do not use QtGui again. If an
> > exception unwound the stack in QtGui, then QtGui is now in an undefined
> > state,
> > which means your application could do worse things than crash.
> 
> How would you then handle std::bad_alloc in case there're a new widget made
> during an event clicked()?

You wouldn't. That situation does not happen under ordinary circumstances.

If std::bad_alloc is thrown, it's most often because you passed some silly 
value to operator new() or passed some invalid data somewhere -- like decoding 
a corrupt QDataStream, which has an absurd size for a QString.

Under legitimate memory allocation conditions, getting std::bad_alloc is 
extremely rare. By the time that the system has so little memory left, it's 
been swapping for a while and the user is already annoyed. In fact, for the OS 
to refuse to allocate memory for you, it usually means its OOM killer has been 
triggered already.

Not to mention that you may run out of memory and be killed for it with no 
notification.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130727/bf6622aa/attachment.sig>


More information about the Interest mailing list