OpenLexocad  27.1
LxApplication.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <QApplication>
4 #include <QMessageBox>
5 
6 
7 
8 class LxApplication : public QApplication
9 {
10 public:
11  LxApplication(int& argc, char** argv) : QApplication(argc, argv)
12  {
13 
14 
15  }
16  virtual bool winEventFilter(MSG* msg, long* result)
17  {
18  return false;
19  }
20 
21  virtual bool notify( QObject * receiver, QEvent * event ) override
22  {
23 
24  if( catchExceptions )
25  {
26  try
27  {
28  return QApplication::notify(receiver, event);
29  }
30  catch(...)
31  {
32  //assert( !"Oops. Forgot to catch exception?" );
33 
34  // may be handle exception here ...
35  // TODO Dietmar
36 
37  qDebug() << "Attention. Forgot to catch exception?";
38  QMessageBox::critical(0, "Attention", QString("<b>Forgot to catch exception?</b>"));
39  }
40  }
41  else
42  return QApplication::notify(receiver, event);
43 
44 
45  return false;
46 
47  }
48 
49 
50 
51 
52  bool catchExceptions = true;
53 
54 
55 
56 };
57 
58 #define lxApp (static_cast<LxApplication *>(QCoreApplication::instance()))
virtual bool winEventFilter(MSG *msg, long *result)
Definition: LxApplication.h:16
virtual bool notify(QObject *receiver, QEvent *event) override
Definition: LxApplication.h:21
LxApplication(int &argc, char **argv)
Definition: LxApplication.h:11
bool catchExceptions
Definition: LxApplication.h:52
Definition: LxApplication.h:8