开发者

Platform independent way of setting a unhandled exception handler using Qt?

开发者 https://www.devze.com 2022-12-16 06:58 出处:网络
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 #

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
}
0

精彩评论

暂无评论...
验证码 换一张
取 消