main.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "mainwindow.h"
  2. #include <QApplication>
  3. #include <QResource>
  4. #include <QDebug>
  5. #include <signal.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <QMessageBox>
  10. MainWindow *wnd;
  11. // Absturtz Handler zum speichern der Annotationen
  12. void segfault_sigaction(int signal, siginfo_t *si, void *arg)
  13. {
  14. if( wnd->getSequenz() )
  15. {
  16. QMessageBox::StandardButton reply =
  17. QMessageBox::question(0, "Fehler", QString( "Es ist ein unerwarteter Fehler aufgetreten und das Programm muss "
  18. "geschlossen werden (Zugriffsfehler auf Speicheradresse " ) +
  19. QString("0x%1").arg((quintptr)si->si_addr, QT_POINTER_SIZE * 2, 16, QChar('0')) + "). Möchten sie die Annotationen speichern?",
  20. QMessageBox::Yes|QMessageBox::No);
  21. if (reply == QMessageBox::Yes) {
  22. wnd->getSequenz()->saveToPath( 0 );
  23. }
  24. }
  25. exit(0);
  26. }
  27. void doStuff(int argc, char *argv[])
  28. {
  29. QResource::registerResource("icons.rcc");
  30. QApplication a(argc, argv);
  31. MainWindow w( &a );
  32. wnd = &w;
  33. struct sigaction sa;
  34. memset(&sa, 0, sizeof(struct sigaction));
  35. sigemptyset(&sa.sa_mask);
  36. sa.sa_sigaction = segfault_sigaction;
  37. sa.sa_flags = SA_SIGINFO;
  38. sigaction(SIGSEGV, &sa, 0);
  39. w.show();
  40. a.exec();
  41. }
  42. // Start des Programms
  43. int main(int argc, char *argv[])
  44. {
  45. numObjects = 0;
  46. doStuff(argc, argv);
  47. qDebug() << "Number of counted memory leaks: " << numObjects;
  48. return 0;
  49. }