Permalink
Browse files

Reuse crash reporter windows.

(mostly to shut up an analyzer warning, but also to prevent people from opening millions of crash logs or feedback windows - we're not a mail client)
  • Loading branch information...
1 parent 361b038 commit 6557e6774939580d2a6dcb01a780a163d37f82c3 @uliwitness committed May 4, 2013
Showing with 25 additions and 3 deletions.
  1. +2 −0 UKCrashReporter.h
  2. +23 −3 UKCrashReporter.m
View
@@ -74,6 +74,8 @@ void UKCrashReporterCheckForCrash( void );
-(IBAction) remindMeLater: (id)sender;
-(IBAction) discardCrashReport: (id)sender;
+-(NSWindow*) window;
+
@end
View
@@ -36,6 +36,9 @@
NSString* UKCrashReporterFindTenFiveCrashReportPath( NSString* appName, NSString* crashLogsFolder );
+
+static UKCrashReporter * sCurrentCrashReporter = nil;
+
// -----------------------------------------------------------------------------
// UKCrashReporterCheckForCrash:
// This submits the crash report to a CGI form as a POST request by
@@ -258,6 +261,12 @@ -(void) awakeFromNib
}
+-(NSWindow*) window
+{
+ return reportWindow;
+}
+
+
-(IBAction) sendCrashReport: (id)sender
{
NSString *boundary = @"0xKhTmLbOuNdArY";
@@ -300,6 +309,8 @@ -(IBAction) sendCrashReport: (id)sender
-(IBAction) remindMeLater: (id)sender
{
[reportWindow orderOut: self];
+ [sCurrentCrashReporter autorelease];
+ sCurrentCrashReporter = nil;
}
@@ -313,6 +324,8 @@ -(IBAction) discardCrashReport: (id)sender
}
[reportWindow orderOut: self];
+ [sCurrentCrashReporter autorelease];
+ sCurrentCrashReporter = nil;
}
@@ -331,7 +344,8 @@ -(void) showFinishedMessage: (NSError*)errMsg
}
[reportWindow orderOut: self];
- [self autorelease];
+ [sCurrentCrashReporter autorelease];
+ sCurrentCrashReporter = nil;
}
@@ -366,13 +380,19 @@ @implementation UKFeedbackProvider
-(IBAction) orderFrontFeedbackWindow: (id)sender
{
- [[UKCrashReporter alloc] init];
+ if( sCurrentCrashReporter )
+ [sCurrentCrashReporter.window makeKeyAndOrderFront: self];
+ else
+ sCurrentCrashReporter = [[UKCrashReporter alloc] init];
}
-(IBAction) orderFrontBugReportWindow: (id)sender
{
- [[UKCrashReporter alloc] init];
+ if( sCurrentCrashReporter )
+ [sCurrentCrashReporter.window makeKeyAndOrderFront: self];
+ else
+ sCurrentCrashReporter = [[UKCrashReporter alloc] init];
}
@end

0 comments on commit 6557e67

Please sign in to comment.