From 2fd534e5d993532737ffa4d6ebb926f10211e38a Mon Sep 17 00:00:00 2001 From: nsubiron Date: Mon, 15 May 2017 15:12:26 +0100 Subject: [PATCH] Fix crash on editor simulation mode --- Source/Carla/Game/CarlaVehicleController.cpp | 25 ++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Source/Carla/Game/CarlaVehicleController.cpp b/Source/Carla/Game/CarlaVehicleController.cpp index f4d926243..118dfa5dc 100644 --- a/Source/Carla/Game/CarlaVehicleController.cpp +++ b/Source/Carla/Game/CarlaVehicleController.cpp @@ -108,18 +108,19 @@ void ACarlaVehicleController::Possess(APawn *aPawn) void ACarlaVehicleController::BeginPlay() { - check(CarlaPlayerState != nullptr); - CarlaPlayerState->Images.Empty(); - const auto NumberOfCameras = SceneCaptureCameras.Num(); - if (NumberOfCameras > 0) { - CarlaPlayerState->Images.AddDefaulted(NumberOfCameras); - for (auto i = 0; i < NumberOfCameras; ++i) { - auto *Camera = SceneCaptureCameras[i]; - check(Camera != nullptr); - auto &Image = CarlaPlayerState->Images[i]; - Image.SizeX = Camera->GetImageSizeX(); - Image.SizeY = Camera->GetImageSizeY(); - Image.PostProcessEffect = Camera->GetPostProcessEffect(); + if (CarlaPlayerState != nullptr) { + CarlaPlayerState->Images.Empty(); + const auto NumberOfCameras = SceneCaptureCameras.Num(); + if (NumberOfCameras > 0) { + CarlaPlayerState->Images.AddDefaulted(NumberOfCameras); + for (auto i = 0; i < NumberOfCameras; ++i) { + auto *Camera = SceneCaptureCameras[i]; + check(Camera != nullptr); + auto &Image = CarlaPlayerState->Images[i]; + Image.SizeX = Camera->GetImageSizeX(); + Image.SizeY = Camera->GetImageSizeY(); + Image.PostProcessEffect = Camera->GetPostProcessEffect(); + } } }