It may not work so well if you have a modal dialog window open when a SIGSEGV happens - hiding the main window may not hide the dialog.The second method worked very well. You are the best!
You could test this by adding a QDialog-based class to your app and override some event (like showEvent()) for the class. In that event, call "raise( SIGSEGV )" to trigger a segmentation fault signal, which should go into your handler. If hiding the main window also hides the dialog, all is good.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
I have a problem. I cannot do this because QDialog also has a function named raise() but without any arguments and I cannot call the function raise(SIGSEGV) from signal.h
Do you know how can I call it without any error?
P.S. the error is "too many arguments for function call". I think the compiler confuses the functions.
You need to remember your C++ basics. To call a non-member function, eg. one in the global namespace, you use the global scope qualifier:Do you know how can I call it without any error?
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
Thank you very much! Not all windows closed when signal was sent, but I wrote this part inside signalHandler() function before showing the QMessageBox:
Qt Code:
widget->hide(); }To copy to clipboard, switch view to plain text mode
Now it is working very well. Thank you again!
Great! Now start practicing defensive programming and debug your programs before you release them so you will never have a need for this kind of message.
If you want to make this kind of signal handler really useful instead of just displaying a message like "Oops, something broke and there is nothing you can do to fix it", you would implement something in your QApplication class that could save any open files and basically try to do whatever is possible to clean up what the user was doing and leave it in a recoverable state.
Just displaying a message and then crashing out isn't much different from simply crashing out as far as the user is concerned if their work is trashed and they lose it all.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
Hello,
I can't find correct solution still.
Thanks & Regards
Cyberops Infosec LLP
Cyberops For : Cyber Security Training in Jaipur, VAPT, Penetration Testing & Winter Training in Jaipur.
What is your question? If you are trying to implement something in the same way as INeedADollar is doing, then there is more than enough information in the code and advice that has been posted in response to his questions for you to do the same thing.I can't find correct solution still.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
Bookmarks