Live Coding: Prevent compiling from the IDE while a Live Coding session is active. Engine runtime creates a global mutex with the executable path in the a name and leaks the handle, then UBT checks for it existing before allowing a build to start.

#rb none
#jira UE-74438

#ROBOMERGE-OWNER: robert.manuszewski
#ROBOMERGE-AUTHOR: ben.marsh
#ROBOMERGE-SOURCE: CL 6957113 in //UE4/Release-4.23/... via CL 6966779
#ROBOMERGE-BOT: CORE (Main -> Dev-Core) (v367-6836689)

[CL 6997861 by ben marsh in Dev-Core branch]
This commit is contained in:
ben marsh
2019-06-14 14:31:36 -04:00
parent b1408518b8
commit 5b60d71b7d
3 changed files with 62 additions and 0 deletions

View File

@@ -291,6 +291,25 @@ bool FLiveCodingModule::StartLiveCoding()
}
LppSetBuildArguments(*Arguments);
// Create a mutex that allows UBT to detect that we shouldn't hot-reload into this executable. The handle to it will be released automatically when the process exits.
FString ExecutablePath = FPaths::ConvertRelativePathToFull(FPlatformProcess::ExecutablePath());
FString MutexName = TEXT("Global\\LiveCoding_");
for (int Idx = 0; Idx < ExecutablePath.Len(); Idx++)
{
TCHAR Character = ExecutablePath[Idx];
if (Character == '/' || Character == '\\' || Character == ':')
{
MutexName += '+';
}
else
{
MutexName += Character;
}
}
ensure(CreateMutex(NULL, Windows::FALSE, *MutexName));
// Configure all the current modules. For non-commandlets, schedule it to be done in the first Tick() so we can batch everything together.
if (IsRunningCommandlet())
{