From a95a055acd77ce76aa35683a24f1e0fde51c4883 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 12 Mar 2019 08:35:17 +0400 Subject: [PATCH] After update try relaunching for 1 second on macOS. --- Telegram/SourceFiles/_other/updater_osx.m | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/_other/updater_osx.m b/Telegram/SourceFiles/_other/updater_osx.m index ea6f0d68b..c93fba25a 100644 --- a/Telegram/SourceFiles/_other/updater_osx.m +++ b/Telegram/SourceFiles/_other/updater_osx.m @@ -266,18 +266,24 @@ int main(int argc, const char * argv[]) { [args addObject:workDir]; } writeLog([[NSArray arrayWithObjects:@"Running application '", appPath, @"' with args '", [args componentsJoinedByString:@"' '"], @"'..", nil] componentsJoinedByString:@""]); - NSError *error = nil; - NSRunningApplication *result = [[NSWorkspace sharedWorkspace] + + for (int i = 0; i < 5; ++i) { + NSError *error = nil; + NSRunningApplication *result = [[NSWorkspace sharedWorkspace] launchApplicationAtURL:[NSURL fileURLWithPath:appPath] options:NSWorkspaceLaunchDefault configuration:[NSDictionary dictionaryWithObject:args forKey:NSWorkspaceLaunchConfigurationArguments] error:&error]; - if (!result) { + if (result) { + closeLog(); + return 0; + } writeLog([[NSString stringWithFormat:@"Could not run application, error %ld: ", (long)[error code]] stringByAppendingString: error ? [error localizedDescription] : @"(nil)"]); + usleep(200000); } closeLog(); - return result ? 0 : -1; + return -1; }