November 29, 2011

Eus Eus
Lab Rat
138 posts

[Solved] Catch application crash and/or display message

 

This might be more C++ then Qt question, sorry about it. Also, I tried searching for few days now, looking for all kind of solutions, nothing seems to work as I want it to.

I am developing an application which heavily uses the clipboard. All that the application does is to monitor the clipboard for certain text and once it finds it, takes out specific parts from the text, sorts and formats them in a certain way and puts them back into the clipboard. The application is working just OK, however the texts it is monitoring for can change every few months. I wont be updated in time when these texts changes, so I cannot update the app in time. Because of that and because of the way I made it search the text, it sometimes crashes.

My question is – is it possible to catch for example the (system) ASSERTS in release builds and display them as messages (yes, tried qInstallMsgHandler(), it doesn’t work in release build). A simple example would be if the app is trying to read from QList which is empty. In such case, my app would just “disappear” without any message. I would like to be able to catch such crashes and display message with information for the users, which information they will be able to send to me and help me resolve the problem faster.

8 replies

November 29, 2011

fluca1978 fluca1978
Lab Rat
529 posts

Well, the difference between a release and a debug mode is almost the debug information it can output autonomously. Since you are trying to understand errors in production environments I suggest you to implement a logging facility to control what your application is doing. And possibly to fix your design to handle special cases. Validating input, even when there is no input, is one of the most important tasks of an application.

November 29, 2011

trollixx trollixx
Lab Rat
31 posts

To handle application crashes we use Google Breakpad [code.google.com]. There’re of course other projects like CrashRpt [code.google.com].

 Signature 

Oleg

November 29, 2011

Eus Eus
Lab Rat
138 posts

Erm, maybe I should have said that I looked at breakpad, but didn’t felt like using that. Maybe I don’t fully understand how exactly it’ll help me in the task, I don’t know….

fluca1978, I know that input validation is important, however the project was started generally as project to help me get involved with Qt, but I want to have something which will help me identify all the pitfalls which I have in the code and help me fix them faster, while helping me build a better help and report system for the app.

November 30, 2011

trollixx trollixx
Lab Rat
31 posts

Using Breakpad or similar tool will allow you to see where in the code the crash occurеd and variable values. So, better than this is only running program in debugger.

 Signature 

Oleg

November 30, 2011

Davy Durham Davy Durham
Lab Rat
9 posts

2nd on breakpad

November 30, 2011

Eus Eus
Lab Rat
138 posts
trollixx wrote:
Using Breakpad or similar tool will allow you to see where in the code the crash occurеd and variable values. So, better than this is only running program in debugger.

That’s exactly the problem man…. I want to be able to show error message to the user, before the app exits. I cannot know all the bugs beforehand, else I would have fixed them, right? So I want to be able to catch runtime problems and warn the users with something minimal but still useful that he will send me to debug the problem =/

December 1, 2011

trollixx trollixx
Lab Rat
31 posts

Breakpad allows you to catch application crash and do whatever you want afterwards, i.e. show message to use and send generated dump to you.

 Signature 

Oleg

December 1, 2011

Eus Eus
Lab Rat
138 posts

Well if there are no more suggestions, I guess that leaves me no choice, lol, will have to check breakpad again. Thanks for the input everyone.

 
  ‹‹ Need help on QTextEdit      If QT uses double buffer to paint, is there any way to get these buffers on Qgraphicsview? ››

You must log in to post a reply. Not a member yet? Register here!