[Qt-interest] Handling exceptions in Qt
Santhosh Y
santhosh at softjin.com
Thu Jul 22 13:47:04 CEST 2010
Hi Sean,
Thanks a lot; It works for me when I work with debug build.
But my catch block is not getting hit in case of release build of my app.
I have added following flag to my project file:
*QMAKE_CXXFLAGS_EXCEPTIONS_ON += -EHa*
This flag has anything to do with build type?
Please reply
Regards
Santhosh
On 7/19/2010 5:42 PM, Sean Harmer wrote:
> Hi,
>
> On Monday 19 July 2010 12:58:20 Santhosh Y wrote:
>
>> I read some where to override an API on QApplication / QCoreApplication
>> for catching exceptions in a Qt application.
>> Can anybody tell me the API which I should override for handling
>> exceptions in my app.
>>
> You need to override bool QCoreApplication::notify(). For example in one
> application we have where a library we are using can throw exceptions we have
> this in a class derived from QCoreApplication:
>
> bool ExceptionApplication::notify( QObject* receiver, QEvent* e )
> {
> try {
> return QApplication::notify( receiver, e );
> }
> catch ( char* err ) {
> qDebug()<< "ExceptionApplication::notify exception caught:"
> << QString( err );
> // Do some other processing here...
> }
>
> return false;
> }
>
> By catching all your possible exceptions here you prevent the exception
> mechanism form unwinding the call stack any further and causing Qt to exit its
> event loop.
>
> HTH,
>
> Sean
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
--
----------------------------------------------------
Y Santhosh Kumar -
Senior Software Engineer,
SoftJin Technologies Pvt Ltd,
www.softjin.com
----------------------------------------------------
Business Disclaimer
____________________________________________________________
This e-mail message and any files transmitted with it are intended solely
for the use of the individual or entity to which they are addressed. It
may contain confidential, proprietary or legally privileged information.
If you are not the intended recipient please be advised that you have
received this message in error and any use is strictly prohibited. Please
immediately delete it and all copies of it from your system, destroy any
hard copies of it and notify the sender by return mail. You must not,
directly or indirectly, use, disclose, distribute, print, or copy any part of
this message if you are not the intended recipient.
___________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100722/5120ac4e/attachment.html
More information about the Qt-interest-old
mailing list