Skip to content

Commit

Permalink
Crash fix for suppressing AppNap on older versions of OS X
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Mizerak authored and Chris Mizerak committed Feb 18, 2016
1 parent c29d073 commit 80a0703
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
24 changes: 15 additions & 9 deletions OSCRouter/EosPlatform_Mac_Native.mm
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,17 @@ + (id)BeginActivity:(const std::string&)reason error:(std::string&)error
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
if(processInfo != nil)
{
const char *reasonStr = ((reason.empty() || reason.c_str()==0)
? "routing started"
: reason.c_str());
activity = [processInfo beginActivityWithOptions:NSActivityUserInitiated|NSActivityLatencyCritical reason:[NSString stringWithUTF8String:reasonStr]];
if(activity == nil)
error = "beginActivityWithOptions failed";
else
[activity retain];
if([processInfo respondsToSelector:@selector(beginActivityWithOptions:reason:)] == YES)
{
const char *reasonStr = ((reason.empty() || reason.c_str()==0)
? "routing started"
: reason.c_str());
activity = [processInfo beginActivityWithOptions:NSActivityUserInitiated|NSActivityLatencyCritical reason:[NSString stringWithUTF8String:reasonStr]];
if(activity == nil)
error = "beginActivityWithOptions failed";
else
[activity retain];
}
}
else
error = "could not get current process";
Expand All @@ -95,7 +98,10 @@ + (void)EndActivity:(id)activity
{
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
if(processInfo != nil)
[processInfo endActivity:activity];
{
if([processInfo respondsToSelector:@selector(endActivity:)] == YES)
[processInfo endActivity:activity];
}

[activity release];
}
Expand Down
2 changes: 1 addition & 1 deletion OSCRouter/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

////////////////////////////////////////////////////////////////////////////////

#define APP_VERSION "0.5"
#define APP_VERSION "0.6"
#define SETTING_LOG_DEPTH "LogDepth"
#define SETTING_FILE_DEPTH "FileDepth"
#define SETTING_LAST_FILE "LastFile"
Expand Down

0 comments on commit 80a0703

Please sign in to comment.