# Handle actor deletion undo in Unreal Editor?

**URL:** <https://forums.unrealengine.com/t/handle-actor-deletion-undo-in-unreal-editor/351245>\
**Category:** C++\
**Tags:** undo, unreal-engine, UE4, question, CPP\
**Created:** [March 21, 2016, 2:49pm UTC](https://forums.unrealengine.com/t/handle-actor-deletion-undo-in-unreal-editor/351245 "2016-03-21T14:49:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_08c2fdfc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_08c2fdfc](https://forums.unrealengine.com/u/anonymous_user_08c2fdfc)\
**Post date:** [March 21, 2016, 2:49pm UTC](https://forums.unrealengine.com/t/handle-actor-deletion-undo-in-unreal-editor/351245/1 "2016-03-21T14:49:19Z")

</div>

I have some objects pointing to a scene component of an actor:

```
class MyObject 
{
    USceneComponent* Component;
}

```

When the actor is deleted, all its components are also deleted. So when the delete action is undone (transaction undo), the component pointer (in `MyObject`) becomes invalid. This is not a problem, but the pointer must be updated after the redo (when the actor and its components are automatically re-created).

How can I detect which actor was created by the redo?

---

<div class="post-metadata">

**Author:** ![gmikhaile](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@gmikhaile](https://forums.unrealengine.com/u/gmikhaile)\
**Post date:** [March 4, 2021, 5:40pm UTC](https://forums.unrealengine.com/t/handle-actor-deletion-undo-in-unreal-editor/351245/2 "2021-03-04T17:40:55Z")

</div>

UPROPERTY() did the trick!

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [March 5, 2021, 2:30am UTC](https://forums.unrealengine.com/t/handle-actor-deletion-undo-in-unreal-editor/351245/3 "2021-03-05T02:30:04Z")

</div>

in general you should UPROPERTY() on all UObject pointers (this include actors), as it breaks memory management, garbage cleaning and you have a risk to encounter invalid pointer.
