mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Don’t access user’s contacts during launch
Instead we access it when either we need to submit a crash report, when the preferences window open (where the contact address is shown), or when creating a new bundle (where email is also used for the bundle’s contact).
This commit is contained in:
@@ -5,6 +5,7 @@ PUBLIC extern NSString* const kUserDefaultsCrashReportsContactInfoKey;
|
||||
|
||||
PUBLIC @interface CrashReporter : NSObject
|
||||
+ (CrashReporter*)sharedInstance;
|
||||
- (void)setupUserDefaultsContact:(id)sender;
|
||||
- (void)applicationDidFinishLaunching:(NSNotification*)aNotification;
|
||||
- (void)postNewCrashReportsToURLString:(NSString*)aURL;
|
||||
@end
|
||||
|
||||
@@ -55,7 +55,7 @@ static std::string create_gzipped_file (std::string const& path)
|
||||
return instance;
|
||||
}
|
||||
|
||||
+ (void)initialize
|
||||
- (void)setupUserDefaultsContact:(id)sender
|
||||
{
|
||||
NSString* name = NSFullUserName();
|
||||
if(ABAddressBook* ab = [ABAddressBook sharedAddressBook])
|
||||
@@ -126,6 +126,15 @@ static std::string create_gzipped_file (std::string const& path)
|
||||
std::vector<std::string> shouldSend;
|
||||
std::set_difference(canSend.begin(), canSend.end(), hasSent.begin(), hasSent.end(), back_inserter(shouldSend));
|
||||
|
||||
std::string __block contact;
|
||||
if(!shouldSend.empty())
|
||||
{
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
[self setupUserDefaultsContact:self];
|
||||
contact = to_s([[NSUserDefaults standardUserDefaults] stringForKey:kUserDefaultsCrashReportsContactInfoKey]);
|
||||
});
|
||||
}
|
||||
|
||||
std::set<std::string> didSend;
|
||||
for(auto report : shouldSend)
|
||||
{
|
||||
@@ -134,7 +143,7 @@ static std::string create_gzipped_file (std::string const& path)
|
||||
{
|
||||
std::map<std::string, std::string> payload, response;
|
||||
payload["hardware"] = hardware_info(HW_MODEL) + "/" + hardware_info(HW_MACHINE) + "/" + hardware_info(HW_NCPU, true);
|
||||
payload["contact"] = to_s([[NSUserDefaults standardUserDefaults] stringForKey:kUserDefaultsCrashReportsContactInfoKey]);
|
||||
payload["contact"] = contact;
|
||||
payload["report"] = "@" + gzippedReport;
|
||||
|
||||
long rc = post_to_server(to_s(aURL), payload, &response);
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
{
|
||||
if(self = [super initWithNibName:@"SoftwareUpdatePreferences" label:@"Software Update" image:[NSImage imageNamed:@"Software Update" inSameBundleAsClass:[self class]]])
|
||||
{
|
||||
[[CrashReporter sharedInstance] setupUserDefaultsContact:self];
|
||||
|
||||
[OakStringListTransformer createTransformerWithName:@"OakSoftwareUpdateChannelTransformer" andObjectsArray:@[ kSoftwareUpdateChannelRelease, kSoftwareUpdateChannelBeta ]];
|
||||
[self bind:@"isChecking" toObject:[SoftwareUpdate sharedInstance] withKeyPath:@"isChecking" options:nil];
|
||||
[self bind:@"lastPoll" toObject:[SoftwareUpdate sharedInstance] withKeyPath:@"lastPoll" options:nil];
|
||||
|
||||
Reference in New Issue
Block a user