Skip to content

Commit

Permalink
macOS: change debugging detection from compile time to runtime; now b…
Browse files Browse the repository at this point in the history
…oth Debug/Release package able to run via double clicking
  • Loading branch information
palxex committed Jun 1, 2018
1 parent ce58bcb commit 29c8943
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions macos/util.mm
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,18 @@ INT UTIL_Platform_Startup(
char* argv[]
)
{
#if !defined(DEBUG) //for ease of debugging(specify resource dir in xcode scheme)
char *p = strstr(argv[0], "/Pal.app/");

if (p != NULL)
if( getppid() == 1 ) //detect whether is debugging; for ease of specify resource dir in debugger
{
char buf[4096];
strcpy(buf, argv[0]);
buf[p - argv[0]] = '\0';
chdir(buf);
char *p = strstr(argv[0], "/Pal.app/");

if (p != NULL)
{
char buf[4096];
strcpy(buf, argv[0]);
buf[p - argv[0]] = '\0';
chdir(buf);
}
}
#endif
return 0;
}

Expand Down

1 comment on commit 29c8943

@sudormroot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

谢谢。

Please sign in to comment.