Files
UnrealEngineUWP/Engine/Source/Programs/ChaosVisualDebugger/Private/Mac/ChaosVisualDebuggerMac.cpp
jack porter 946b30a59a Remove UE3/UE4 references
#jira UE-112108
#jira UE-111469
#jira UE-111456
#jira UE-111451
#jira UE-111331
#jira UE-111149
#jira UE-111136
#jira UE-110941
#jira UE-104701
#rb trivial
[FYI] Chris.Babcock
#preflight 606446947a99880001b3cbac

#ROBOMERGE-SOURCE: CL 15872931 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v786-15839533)

[CL 15872932 by jack porter in ue5-main branch]
2021-03-31 06:40:14 -04:00

119 lines
2.6 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "ChaosVisualDebuggerMain.h"
#include "HAL/ExceptionHandling.h"
#include "LaunchEngineLoop.h"
#include "Misc/CommandLine.h"
#include "Mac/CocoaThread.h"
static FString GSavedCommandLine;
@interface UEAppDelegate : NSObject<NSApplicationDelegate, NSFileManagerDelegate>
{
}
@end
@implementation UEAppDelegate
//handler for the quit apple event used by the Dock menu
- (void)handleQuitEvent:(NSAppleEventDescriptor*)Event withReplyEvent:(NSAppleEventDescriptor*)ReplyEvent
{
[self requestQuit:self];
}
- (IBAction)requestQuit:(id)Sender
{
RequestEngineExit(TEXT("requestQuit"));
}
- (void) runGameThread:(id)Arg
{
FPlatformMisc::SetGracefulTerminationHandler();
FPlatformMisc::SetCrashHandler(nullptr);
#if !UE_BUILD_SHIPPING
if (FParse::Param(*GSavedCommandLine,TEXT("crashreports")))
{
GAlwaysReportCrash = true;
}
#endif
#if UE_BUILD_DEBUG
if (!GAlwaysReportCrash)
#else
if (FPlatformMisc::IsDebuggerPresent() && !GAlwaysReportCrash)
#endif
{
ChaosVisualDebuggerMain(*GSavedCommandLine);
}
else
{
GIsGuarded = 1;
ChaosVisualDebuggerMain(*GSavedCommandLine);
GIsGuarded = 0;
}
FEngineLoop::AppExit();
[NSApp terminate: self];
}
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)Sender;
{
if(!IsEngineExitRequested() || ([NSThread gameThread] && [NSThread gameThread] != [NSThread mainThread]))
{
[self requestQuit:self];
return NSTerminateLater;
}
else
{
return NSTerminateNow;
}
}
- (void)applicationDidFinishLaunching:(NSNotification *)Notification
{
//install the custom quit event handler
NSAppleEventManager* appleEventManager = [NSAppleEventManager sharedAppleEventManager];
[appleEventManager setEventHandler:self andSelector:@selector(handleQuitEvent:withReplyEvent:) forEventClass:kCoreEventClass andEventID:kAEQuitApplication];
RunGameThread(self, @selector(runGameThread:));
}
@end
int main(int argc, char *argv[])
{
for (int32 Option = 1; Option < argc; Option++)
{
GSavedCommandLine += TEXT(" ");
FString Argument(ANSI_TO_TCHAR(argv[Option]));
if (Argument.Contains(TEXT(" ")))
{
if (Argument.Contains(TEXT("=")))
{
FString ArgName;
FString ArgValue;
Argument.Split( TEXT("="), &ArgName, &ArgValue );
Argument = FString::Printf( TEXT("%s=\"%s\""), *ArgName, *ArgValue );
}
else
{
Argument = FString::Printf(TEXT("\"%s\""), *Argument);
}
}
GSavedCommandLine += Argument;
}
SCOPED_AUTORELEASE_POOL;
[NSApplication sharedApplication];
[NSApp setDelegate:[UEAppDelegate new]];
[NSApp run];
return 0;
}