mirror of
https://github.com/overte-org/overte.git
synced 2025-06-15 22:19:35 +02:00
Merge pull request #15840 from danteruiz/launcher-issues
BUGZ-837: Fix Launcher crash (mac)
This commit is contained in:
commit
d13b8d354c
2 changed files with 18 additions and 11 deletions
|
@ -6,12 +6,18 @@
|
||||||
@implementation LatestBuildRequest
|
@implementation LatestBuildRequest
|
||||||
|
|
||||||
- (NSInteger) getCurrentVersion {
|
- (NSInteger) getCurrentVersion {
|
||||||
NSString* interfaceAppPath = [[Launcher.sharedLauncher getAppPath] stringByAppendingString:@"interface.app"];
|
NSInteger currentVersion;
|
||||||
NSError * error = nil;
|
@try {
|
||||||
Interface * interface = [[Interface alloc] initWith:interfaceAppPath];
|
NSString* interfaceAppPath = [[Launcher.sharedLauncher getAppPath] stringByAppendingString:@"interface.app"];
|
||||||
NSInteger currentVersion = [interface getVersion:&error];
|
NSError * error = nil;
|
||||||
if (currentVersion == 0 && error != nil) {
|
Interface * interface = [[Interface alloc] initWith:interfaceAppPath];
|
||||||
NSLog(@"can't get version from interface, falling back to settings: %@", error);
|
currentVersion = [interface getVersion:&error];
|
||||||
|
if (currentVersion == 0 && error != nil) {
|
||||||
|
NSLog(@"can't get version from interface, falling back to settings: %@", error);
|
||||||
|
currentVersion = [Settings.sharedSettings latestBuildVersion];
|
||||||
|
}
|
||||||
|
} @catch (NSException *exception) {
|
||||||
|
NSLog(@"an exception was thrown: %@", exception);
|
||||||
currentVersion = [Settings.sharedSettings latestBuildVersion];
|
currentVersion = [Settings.sharedSettings latestBuildVersion];
|
||||||
}
|
}
|
||||||
return currentVersion;
|
return currentVersion;
|
||||||
|
@ -58,6 +64,7 @@
|
||||||
BOOL appDirectoryExist = [fileManager fileExistsAtPath:[[sharedLauncher getAppPath] stringByAppendingString:@"interface.app"]];
|
BOOL appDirectoryExist = [fileManager fileExistsAtPath:[[sharedLauncher getAppPath] stringByAppendingString:@"interface.app"]];
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
|
||||||
NSInteger currentVersion = [self getCurrentVersion];
|
NSInteger currentVersion = [self getCurrentVersion];
|
||||||
NSLog(@"Latest Build Request -> does build directory exist: %@", appDirectoryExist ? @"TRUE" : @"FALSE");
|
NSLog(@"Latest Build Request -> does build directory exist: %@", appDirectoryExist ? @"TRUE" : @"FALSE");
|
||||||
NSLog(@"Latest Build Request -> current version: %ld", currentVersion);
|
NSLog(@"Latest Build Request -> current version: %ld", currentVersion);
|
||||||
|
|
|
@ -5,13 +5,13 @@ void redirectLogToDocuments()
|
||||||
{
|
{
|
||||||
NSString* filePath = [[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) objectAtIndex:0]
|
NSString* filePath = [[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) objectAtIndex:0]
|
||||||
stringByAppendingString:@"/Launcher/"];
|
stringByAppendingString:@"/Launcher/"];
|
||||||
|
|
||||||
if (![[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
|
if (![[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
|
||||||
NSError * error = nil;
|
NSError * error = nil;
|
||||||
[[NSFileManager defaultManager] createDirectoryAtPath:filePath withIntermediateDirectories:TRUE attributes:nil error:&error];
|
[[NSFileManager defaultManager] createDirectoryAtPath:filePath withIntermediateDirectories:TRUE attributes:nil error:&error];
|
||||||
}
|
}
|
||||||
NSString *pathForLog = [filePath stringByAppendingPathComponent:@"log.txt"];
|
NSString *pathForLog = [filePath stringByAppendingPathComponent:@"log.txt"];
|
||||||
|
|
||||||
freopen([pathForLog cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr);
|
freopen([pathForLog cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,12 +23,12 @@ int main(int argc, const char* argv[]) {
|
||||||
NSLog(@"launcher is already running");
|
NSLog(@"launcher is already running");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[NSApplication sharedApplication];
|
[NSApplication sharedApplication];
|
||||||
Launcher* sharedLauncher = [Launcher sharedLauncher];
|
Launcher* sharedLauncher = [Launcher sharedLauncher];
|
||||||
[Settings sharedSettings];
|
[Settings sharedSettings];
|
||||||
[NSApp setDelegate: sharedLauncher];
|
[NSApp setDelegate: sharedLauncher];
|
||||||
|
|
||||||
// Referenced from https://stackoverflow.com/questions/9155015/handle-cmd-q-in-cocoa-application-and-menu-item-quit-application-programmatic
|
// Referenced from https://stackoverflow.com/questions/9155015/handle-cmd-q-in-cocoa-application-and-menu-item-quit-application-programmatic
|
||||||
id menubar = [[NSMenu new] autorelease];
|
id menubar = [[NSMenu new] autorelease];
|
||||||
id appMenuItem = [[NSMenuItem new] autorelease];
|
id appMenuItem = [[NSMenuItem new] autorelease];
|
||||||
|
@ -40,7 +40,7 @@ int main(int argc, const char* argv[]) {
|
||||||
id quitMenuItem = [[[NSMenuItem alloc] initWithTitle:quitTitle action:@selector(terminate:) keyEquivalent:@"q"] autorelease];
|
id quitMenuItem = [[[NSMenuItem alloc] initWithTitle:quitTitle action:@selector(terminate:) keyEquivalent:@"q"] autorelease];
|
||||||
[appMenu addItem:quitMenuItem];
|
[appMenu addItem:quitMenuItem];
|
||||||
[appMenuItem setSubmenu:appMenu];
|
[appMenuItem setSubmenu:appMenu];
|
||||||
|
|
||||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:TRUE];
|
[[NSApplication sharedApplication] activateIgnoringOtherApps:TRUE];
|
||||||
return NSApplicationMain(argc, argv);
|
return NSApplicationMain(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue