Platform independent way of setting a unhandled exception handler using Qt?
Mac OS X (Cocoa) NSSetUncaughtExceptionHandler
Windows SetUnhandledExceptionFilter
Is there a platform independent way to d开发者_运维问答o this using Qt?
Would it really be so bad to have to write #ifdefs around this? It's just a single instance and you'll never have to look at it again once you finish it. That being said at least on Windows, I'd encourage you to not do this, and instead register for Vista+'s Restart Manager if it's available.
What about obvious handler in main()? I mean your application have following lines:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow mainWin;
mainWin.show();
return a.exec();
}
What about simple wrap it with:
try{
QApplication a(argc, argv);
...
}
catch //catches any previously unhandled
{
//do graceful exit
}
精彩评论