tags:

views:

42

answers:

2

Mac OS X (Cocoa) NSSetUncaughtExceptionHandler

Windows SetUnhandledExceptionFilter

Is there a platform independent way to do this using Qt?

A: 

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
}
Dewfy
This isn't the same semantics at least on Windows, as it won't catch SEH exceptions
Paul Betts
i'm afraid this is the only portable way.
lyxera
+1  A: 

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.

Paul Betts
it is not so bad. as a matter of fact, i've already done so. just wanna check whether i have missed a cleaner way of doing this.
lyxera