QXRD  0.11.16
qxrd.cpp
Go to the documentation of this file.
1 #include "qxrddebug.h"
2 #include <QApplication>
3 
4 #include "qxrdapplication.h"
5 #include "qxrdapplication-ptr.h"
6 #include "qxrdwindow.h"
7 #include "qxrdsplashscreen.h"
8 #include "qxrdsplashscreen-ptr.h"
9 #include <stdio.h>
10 #include <QSplashScreen>
11 #include "qcepdataobject.h"
12 
13 #if defined(Q_OS_UNIX) && !defined(Q_OS_MACX)
14 #include <mcheck.h>
15 #endif
16 
26 int main(int argc, char *argv[])
27 {
28 #if defined(Q_OS_UNIX) && !defined(Q_OS_MACX)
29  mtrace();
30 #endif
31 
32  g_DebugLevel = QSharedPointer<QxrdDebugDictionary>(new QxrdDebugDictionary());
33 
34  if (qcepDebug(DEBUG_APP)) {
35  printf("App starts\n");
36  }
37 
38  int res = 0;
39 
40  {
42  new QxrdApplication(argc, argv));
43 
44  if (app->init(app, argc, argv)) {
45  if (app->get_GuiWanted()) {
46  res = app->exec();
47  } else {
48  app->processEvents();
49  app->exit();
50  }
51 
53  while(1) {}
54  }
55  }
56  }
57 
58  if (qcepDebug(DEBUG_APP)) {
59  printf("App finishes\n");
60  }
61 
62  int nObjAlloc = QcepObject::allocatedObjects();
63  int nObjDeleted = QcepObject::deletedObjects();
64 
65  int nDataAlloc = QcepDataObject::allocatedObjects();
66  int nDataDeleted = QcepDataObject::deletedObjects();
67 
68  quint64 allocated = QcepAllocator::allocatedMemory();
69 
70 #ifdef QT_NO_DEBUG
71  bool printIt = (nObjAlloc != nObjDeleted) || (nDataAlloc != nDataDeleted) || (allocated != 0);
72 #else
73  bool printIt = true;
74 #endif
75 
76  if (printIt) {
77  printf("%d objects allocated\n", nObjAlloc);
78  printf("%d objects deleted\n", nObjDeleted);
79  printf("%d objects leaked\n", nObjAlloc - nObjDeleted);
80 
81  printf("%d data objects allocated\n", nDataAlloc);
82  printf("%d data objects deleted\n", nDataDeleted);
83  printf("%d data objects leaked\n", nDataAlloc - nDataDeleted);
84 
85  printf("%Ld bytes still allocated\n", allocated);
86  }
87 
88 #ifndef QT_NO_DEBUG
89  if (nObjAlloc != nObjDeleted) {
90  int i=0;
92  printf("%d : %s\n", i++, qPrintable(obj->objectName()));
93  }
94  }
95 #endif
96 
97  return res;
98 }
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
static quint64 allocatedMemory()
static int deletedObjects()
int main(int argc, char *argv[])
Definition: qxrd.cpp:26
static int deletedObjects()
Definition: qcepobject.cpp:55
static int allocatedObjects()
static QSet< QcepObject * > allocatedObjectsSet()
Definition: qcepobject.cpp:61
QSharedPointer< QcepDebugDictionary > g_DebugLevel
Definition: qcepdebug.cpp:4
static int allocatedObjects()
Definition: qcepobject.cpp:50
QSharedPointer< QxrdApplication > QxrdApplicationPtr