Better logging when destroying actors
This commit is contained in:
parent
21800007b4
commit
3c1f23a3fa
|
@ -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:",
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue