From 9ee0ad84de78177558307de092eba5c5bb00392c Mon Sep 17 00:00:00 2001 From: nsubiron Date: Tue, 4 Apr 2017 12:44:46 +0200 Subject: [PATCH] Workaround for #10 --- Source/Carla/Carla.Build.cs | 25 ++++++++++++++----- .../carla/server/CarlaCommunication.cpp | 2 +- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Source/Carla/Carla.Build.cs b/Source/Carla/Carla.Build.cs index 09fea87ba..99cfd0ce0 100644 --- a/Source/Carla/Carla.Build.cs +++ b/Source/Carla/Carla.Build.cs @@ -5,10 +5,6 @@ using UnrealBuildTool; public class Carla : ModuleRules { - // Apparently, Unreal uses the Release C++ Runtime (CRT) even in debug mode, - // so unless we recompile the engine we cannot link the debug libraries. - private readonly bool bUseDebugLibs = false; - public Carla(TargetInfo Target) { PublicIncludePaths.AddRange( @@ -67,6 +63,23 @@ public class Carla : ModuleRules return (Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32); } + private bool UseDebugLibs(TargetInfo Target) + { + if (IsWindows(Target)) + { + // In Windows, Unreal uses the Release C++ Runtime (CRT) even in debug + // mode, so unless we recompile the engine we cannot link the debug + // libraries. + return false; + } + else + { + // On Linux on the other hand, we need to use the version of the libraries + // without optimizations due to the crash in the std::string destructor. + return true; + } + } + private void AddBoostDependency(TargetInfo Target) { if (IsWindows(Target)) @@ -102,7 +115,7 @@ public class Carla : ModuleRules { string ProtobufRoot = System.Environment.GetEnvironmentVariable("PROTOBUF_ROOT"); string ProtobufLib; - if (bUseDebugLibs) + if (UseDebugLibs(Target)) { ProtobufRoot = Path.Combine(ProtobufRoot, "Debug"); ProtobufLib = "libprotobufd.lib"; @@ -144,7 +157,7 @@ public class Carla : ModuleRules string CarlaServerLibPath = Path.Combine(ModuleDirectory, "..", "CarlaServer/lib"); string CarlaServerLibBaseName; - if (bUseDebugLibs) + if (UseDebugLibs(Target)) { CarlaServerLibBaseName = "carlaserverd"; } diff --git a/Source/CarlaServer/source/carla/server/CarlaCommunication.cpp b/Source/CarlaServer/source/carla/server/CarlaCommunication.cpp index 061679363..a3d486bdf 100644 --- a/Source/CarlaServer/source/carla/server/CarlaCommunication.cpp +++ b/Source/CarlaServer/source/carla/server/CarlaCommunication.cpp @@ -232,7 +232,7 @@ namespace server { // Protobuf produces a segmentation fault in the destructor of the Scene // when called from Unreal Engine in Linux. As a workaround, we added this // cute memory leak. - /// @todo Fix the memory leak! + /// @todo #10 Fix the memory leak! Scene *scene = new Scene; _proto->LoadScene(*scene, values);