[Interest] Survey: do you override QCoreApplication::notify? Why?

Guido Seifert wargand at gmx.de
Fri Apr 17 20:48:26 CEST 2015


Thanks, got it.... Just a bit different than you proposed :-)

My problem was to get the thrown object in the terminate handler. 
I searched for that, but it looks like there really is no such
function.  

However, with this trick in the custom terminate it is possible 
to get the desired object indirectly. Probably c++11 only:

> std::exception_ptr exptr = std::current_exception();
> try {
>   std::rethrow_exception(exptr);
> }
> catch (MyErrorObject &error) {
>  qDebug() << "Uncaught exception" << error.message;
> }

Though a std::exception_ptr exptr cannot be cast directly into the thrown
object type, it can be rethrowen in the terminate handler and immediately 
caught as the expected error object.

Your other solution looks plausible, Thiago, but with the above
method I don't need to change the workflow I am used to at all.
Instead of try/catching around notify, I just add above terminate 
handler. Problem solved. :-)

Guido



More information about the Interest mailing list