UActorComponent::IsBeingDestroyed
#include "Components/ActorComponent.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallableconst
Description
Returns true if the component has begun its destruction sequence but has not yet been fully destroyed. Useful to guard against use-after-destroy in async or deferred callbacks.
Caveats & Gotchas
- • This returns true from the moment BeginDestroy is entered through to garbage collection. If you hold a raw pointer to a component, this check is insufficient — prefer TWeakObjectPtr and IsValid() to detect pending destruction from external code.
- • Components being destroyed will still tick until their owning actor's EndPlay completes, so a ticking component may return true from IsBeingDestroyed during its own TickComponent.
Signature
UFUNCTION(BlueprintCallable, Category="Components", meta=(DisplayName="Is Component Being Destroyed"))
bool IsBeingDestroyed() const Return Type
bool Example
Guard a delegate callback against destroyed components C++
MyTimerHandle = GetWorld()->GetTimerManager().SetTimerForNextTick([WeakComp = TWeakObjectPtr<UMyComponent>(this)]()
{
if (WeakComp.IsValid() && !WeakComp->IsBeingDestroyed())
{
WeakComp->DoWork();
}
}); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?