Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt: Catch application crash and display custom window

Tags:

qt

I'd like our application to have a special window that catches crashes. Such window would have the ability to electronically send us the stack trace (on Mac), or the .dmp files on windows.

I can handle the window and its internal functionality -- but how does one catch an application crash in time to gracefully display a custom window?

I'm with Qt 4.8.5

like image 609
JasonGenX Avatar asked Nov 12 '22 21:11

JasonGenX


2 Answers

First - with crash I understand things like access violation, division by 0 etc., not exceptions that you throw yourself - these can be handled with implementing QApplication::notify. If you need platform independent solution then i guess you would have to make a wrapper for the functionality on each platform:

  • Un Linux, Mac, install a signal handler and show the window from there displaying maybe some optional signal info etc.
  • On Windows I guess you could wrap everything with

    __try { ... } __except { ... }

Maybe you can subclass the QApplication and in your class actually handle the signal handler installation / add try-except handlers (depending on the platform) and then call some generic method where you do all setup and begin the event loop. That is just my two cents.

like image 57
Rudolfs Bundulis Avatar answered Nov 15 '22 12:11

Rudolfs Bundulis


Working with Qt 4 years ago, I was in need of the same functionality.

Don't reinvent the wheel. I used Crashrpt with success. Comes with much needed features for user support.

https://code.google.com/p/crashrpt/

like image 24
Hernán Avatar answered Nov 15 '22 13:11

Hernán