recover from exception on iOS and macOS using signals and log the stacktrace
This commit is contained in:
@@ -19,32 +19,6 @@
|
||||
std::deque<std::packaged_task<void()>> tasklist;
|
||||
std::mutex task_mutex;
|
||||
|
||||
void global_exception_handler(NSException* e)
|
||||
{
|
||||
NSAlert *alert = [NSAlert alertWithMessageText:@"Recovery"
|
||||
defaultButton:@"OK" alternateButton:@"Cancel"
|
||||
otherButton:nil informativeTextWithFormat:@"Exception"];
|
||||
[alert runModal];
|
||||
|
||||
if (App::I.canvas && App::I.canvas->m_canvas)
|
||||
App::I.canvas->m_canvas->project_save_thread(App::I.data_path + "/recovery.ppi");
|
||||
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
void global_signal_handler(int e)
|
||||
{
|
||||
NSAlert *alert = [NSAlert alertWithMessageText:@"Recovery"
|
||||
defaultButton:@"OK" alternateButton:@"Cancel"
|
||||
otherButton:nil informativeTextWithFormat:@"Signal"];
|
||||
[alert runModal];
|
||||
|
||||
if (App::I.canvas && App::I.canvas->m_canvas)
|
||||
App::I.canvas->m_canvas->project_save_thread(App::I.data_path + "/recovery.ppi");
|
||||
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
@implementation View
|
||||
- (void)async_lock
|
||||
{
|
||||
@@ -451,6 +425,8 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
|
||||
}
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"NSApplicationCrashOnExceptions": @YES }];
|
||||
|
||||
if (!App::I.check_license())
|
||||
return;
|
||||
|
||||
@@ -492,9 +468,8 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
|
||||
|
||||
int main(int argc, const char * argv[])
|
||||
{
|
||||
install_global_handlers();
|
||||
AppOSX* app = [AppOSX sharedApplication];
|
||||
NSSetUncaughtExceptionHandler(&global_exception_handler);
|
||||
signal(SIGFPE, global_signal_handler);
|
||||
[app run];
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user