#include "application.h" #include #include #include #include Application::Application( int & argc, char ** argv) : QApplication(argc,argv) { qDebug()<type()==(QEvent::Type)ExceptionEvent::Type){ ExceptionEvent *e=static_cast(event); Q_ASSERT( qApp->thread()==QThread::currentThread() ); exception(e->thread,e->object,e->event,e->message); } } void Application::exception(QThread *t,QObject *o, QEvent *e,const QString &message){ if( QThread::currentThread()==qApp->thread() ){ QMessageBox::information(0,tr("Исключение"),message); }else{ postEvent(this,new ExceptionEvent(t,o,e,message)); } } void Application::exception(QObject *o, QEvent *e,const QString &message){ exception(QThread::currentThread(),o,e,message); } bool Application::notify( QObject *o, QEvent *e ){ try { return QApplication::notify(o, e); } catch(const QString &message){ exception(o,e,message); } catch(const char *message){ exception(o,e,message); } catch(QByteArray message){ exception(o,e,message); } catch(std::exception ex){ exception(o,e,ex.what()); } catch(...){ exception(o,e,"Unknown"); } return true; }