From b981abc73ac8e8bc9d74cb3432c06d1aa7995aac Mon Sep 17 00:00:00 2001 From: Leo Natan Date: Wed, 5 Dec 2018 18:26:03 +0200 Subject: [PATCH] Fix rare crash when closing a document. --- .../DetoxInstruments/DTXApplicationDelegate.m | 1 + .../DetoxInstruments/Document/DTXRecordingDocument.m | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/DetoxInstruments/DetoxInstruments/DTXApplicationDelegate.m b/DetoxInstruments/DetoxInstruments/DTXApplicationDelegate.m index e46f6814..02765533 100644 --- a/DetoxInstruments/DetoxInstruments/DTXApplicationDelegate.m +++ b/DetoxInstruments/DetoxInstruments/DTXApplicationDelegate.m @@ -95,6 +95,7 @@ - (void)verifyLldbInitIsNotBroken - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { [[NSUserDefaults standardUserDefaults] registerDefaults:@{@"DTXProfilingConfigurationUseDefaultConfiguration": @YES}]; + [[NSUserDefaults standardUserDefaults] registerDefaults:@{@"DTXSelectedProfilingConfiguration_timeLimit": @2}]; [[NSUserDefaults standardUserDefaults] registerDefaults:@{@"DTXSelectedProfilingConfiguration_timeLimitType": @1}]; if([[NSUserDefaults standardUserDefaults] boolForKey:@"DTXProfilingConfigurationUseDefaultConfiguration"]) diff --git a/DetoxInstruments/DetoxInstruments/Document/DTXRecordingDocument.m b/DetoxInstruments/DetoxInstruments/Document/DTXRecordingDocument.m index 408e29f1..a38ac7f9 100644 --- a/DetoxInstruments/DetoxInstruments/Document/DTXRecordingDocument.m +++ b/DetoxInstruments/DetoxInstruments/Document/DTXRecordingDocument.m @@ -442,7 +442,7 @@ - (NSString *)defaultDraftName - (void)canCloseDocumentWithDelegate:(id)delegate shouldCloseSelector:(SEL)shouldCloseSelector contextInfo:(void *)contextInfo { #ifndef CLI - if(self.documentState < DTXRecordingDocumentStateLiveRecordingFinished) + if(self.documentState == DTXRecordingDocumentStateLiveRecording) { [self stopLiveRecording]; } @@ -482,8 +482,11 @@ - (void)popGroup - (void)stopLiveRecording { - dispatch_block_cancel(_pendingCancelBlock); - _pendingCancelBlock = nil; + if(_pendingCancelBlock != nil) + { + dispatch_block_cancel(_pendingCancelBlock); + _pendingCancelBlock = nil; + } [self remoteProfilingClientDidStopRecording:_remoteProfilingClient];