code guideline

Thiago Macieira thiago at
Wed Jul 9 19:20:35 BST 2014

On Saturday 28 June 2014 08:51:42 Rodrigo Bonifacio wrote:
> Dear all, is there any code guideline that recommends developers to avoid
> the use of exception handling mechanisms within the core libraries of KDE?

I'm going to let others speak about the use of exceptions in your own code, 
but note this:

Qt classes are not exception-safe.

So if you are allowed to use exceptions in your part of the KDE libraries,  
make sure that you don't:

 a) use Qt container types, like QList and QVector, on types that may throw on 
construction or copying
 b) let exceptions escape back into Qt code, including:
  1) slot activation
  2) event handling
  3) callbacks (such as qSort)

Using QString and QByteArray in code that uses exceptions is mostly safe 
because no exception can happen inside them. Stack unwinding would be no 
different than a regular end of scope anyway.

Thiago Macieira - thiago (AT) - thiago (AT)
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

More information about the kde-core-devel mailing list