Better logging when destroying actors

This commit is contained in:
nsubiron 2018-10-18 20:38:14 +02:00
parent 21800007b4
commit 3c1f23a3fa
2 changed files with 14 additions and 2 deletions

View File

@ -13,7 +13,7 @@ namespace carla {
namespace client {
Sensor::~Sensor() {
if (IsAlive()) {
if (IsAlive() && _is_listening) {
log_warning(
"sensor object went out of the scope but the sensor is still alive",
"in the simulation:",

View File

@ -70,10 +70,22 @@ TPair<EActorSpawnResultStatus, FActorView> FActorDispatcher::SpawnActor(
bool FActorDispatcher::DestroyActor(AActor *Actor)
{
if ((Actor != nullptr) && Actor->Destroy())
if (Actor == nullptr) {
UE_LOG(LogCarla, Error, TEXT("Trying to destroy nullptr actor"));
return false;
}
auto View = Registry.Find(Actor);
if (!View.IsValid()) {
UE_LOG(LogCarla, Error, TEXT("Trying to destroy actor that is not in the registry"));
return false;
}
const auto &Id = View.GetActorDescription()->Id;
UE_LOG(LogCarla, Log, TEXT("Destroying actor '%s'"), *Id);
if (Actor->Destroy())
{
Registry.Deregister(Actor);
return true;
}
UE_LOG(LogCarla, Log, TEXT("Failed to destroy actor '%s'!"), *Id);
return false;
}