# Attempting to replace an object that hasn't been fully loaded (UserWidget)

**URL:** <https://forums.unrealengine.com/t/attempting-to-replace-an-object-that-hasnt-been-fully-loaded-userwidget/393851>\
**Category:** UI\
**Tags:** UProperty, initialize, unreal-engine, crash, Widget, CPP, question\
**Created:** [May 17, 2017, 3:10pm UTC](https://forums.unrealengine.com/t/attempting-to-replace-an-object-that-hasnt-been-fully-loaded-userwidget/393851 "2017-05-17T15:10:48Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_4b3639a6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4b3639a6](https://forums.unrealengine.com/u/anonymous_user_4b3639a6)\
**Post date:** [May 17, 2017, 3:10pm UTC](https://forums.unrealengine.com/t/attempting-to-replace-an-object-that-hasnt-been-fully-loaded-userwidget/393851/1 "2017-05-17T15:10:48Z")

</div>

Hey guys,

the last 2 days I had a weird issue where I couldnt run my game without the editor crashing. I just fixed it but its really weird.  
After crashing the error report showed this:

 ![138236-screenshot+2017-05-17+17.00.30.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/1/0/d1004c89e79be143ccbbcd853f75a8623be6e4b9.png)

I had a UPROPERTY UserWidget in my actor. I marked it as UPROPERTY so that it wont be garbage collected.

Is this maybe a bug?

Greetings

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [May 18, 2017, 1:46pm UTC](https://forums.unrealengine.com/t/attempting-to-replace-an-object-that-hasnt-been-fully-loaded-userwidget/393851/2 "2017-05-18T13:46:20Z")

</div>

Hey -

Just to clarify, is this the you were able to fix or is this a different? What did you do to fix the initially? When you got this report, did you click the Send button? Is there any other information you can provide to help me reproduce/investigate the on my end?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4b3639a6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4b3639a6](https://forums.unrealengine.com/u/anonymous_user_4b3639a6)\
**Post date:** [May 18, 2017, 5:57pm UTC](https://forums.unrealengine.com/t/attempting-to-replace-an-object-that-hasnt-been-fully-loaded-userwidget/393851/3 "2017-05-18T17:57:32Z")

</div>

yeah the is fixed. But I don’t understand why its fixed.  
I had an Actor class which had a UPROPERTY() tagged UserWidget ptr as a member.  
After deleting the UPROPERTY() tag everything worked fine.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [May 18, 2017, 6:33pm UTC](https://forums.unrealengine.com/t/attempting-to-replace-an-object-that-hasnt-been-fully-loaded-userwidget/393851/4 "2017-05-18T18:33:54Z")

</div>

Without knowing more about the code being used I can’t say what the cause of the was, but removing UPROPERTY makes it so that the property is not recognized by the editor. It still exists and can be used in code, but it cannot be called/referenced from blueprints or anything else in the editor.

Cheers

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4b3639a6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4b3639a6](https://forums.unrealengine.com/u/anonymous_user_4b3639a6)\
**Post date:** [May 19, 2017, 2:52am UTC](https://forums.unrealengine.com/t/attempting-to-replace-an-object-that-hasnt-been-fully-loaded-userwidget/393851/5 "2017-05-19T02:52:20Z")

</div>

Yeah I know ^^  
That should be its purpose. But something went wrong.  
Do you maybe know why StaticDuplicateObject was called on the UPROPERTY UserWidget?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [May 19, 2017, 11:15am UTC](https://forums.unrealengine.com/t/attempting-to-replace-an-object-that-hasnt-been-fully-loaded-userwidget/393851/6 "2017-05-19T11:15:56Z")

</div>

Without seeing the code being used I can’t say for sure why the UPROPERTY would cause a. If you could provide the class with the UPROPERTY we can investigate further what is causing the.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4b3639a6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4b3639a6](https://forums.unrealengine.com/u/anonymous_user_4b3639a6)\
**Post date:** [May 20, 2017, 1:22pm UTC](https://forums.unrealengine.com/t/attempting-to-replace-an-object-that-hasnt-been-fully-loaded-userwidget/393851/7 "2017-05-20T13:22:57Z")

</div>

Here is the Header File of the class.  
Most of the functions are static cause its a managing UI Class. I had to make it an Actor because of various reasons

> **[// Fill out your copyright notice in the Description page of Project Settings....](https://pastebin.com/7cdKAhmR)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [May 23, 2017, 11:57am UTC](https://forums.unrealengine.com/t/attempting-to-replace-an-object-that-hasnt-been-fully-loaded-userwidget/393851/8 "2017-05-23T11:57:28Z")

</div>

I don’t see a reference to UserWidget in the class header you provided, which variable are you referring to that you had to remove the UPROPERTY from? Additionally, how is that property being used in the source file? When you say that you couldn’t run your game, does that mean that the occurs when you try to play in editor or simply when you open the project?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4b3639a6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4b3639a6](https://forums.unrealengine.com/u/anonymous_user_4b3639a6)\
**Post date:** [May 23, 2017, 1:42pm UTC](https://forums.unrealengine.com/t/attempting-to-replace-an-object-that-hasnt-been-fully-loaded-userwidget/393851/9 "2017-05-23T13:42:02Z")

</div>

It’s in line 150

It was used to store the ptr to the currently focused widget. For example, when I’m hovering a Widget with the mouse, it tells the UISystem to set this Widget into focus.  
I thought I’ll make it a UPROPERTY because some pointers are garbage collected after 2 minutes ingame. In this case the reference cant be lost because the ptr is provided from outside this class, but I did it just in case.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [May 23, 2017, 7:01pm UTC](https://forums.unrealengine.com/t/attempting-to-replace-an-object-that-hasnt-been-fully-loaded-userwidget/393851/10 "2017-05-23T19:01:14Z")

</div>

The pointer at line 150 is of the type `UFocusableWidget` which I can’t find a reference to in the source code. Is this a custom class you created? Also, how is this pointer being used in your source (.cpp) file? Since you are trying to use widget code in your own code, did you add “UMG”, “Slate”, and “SlateCore” to your ProjectName.build.cs file?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4b3639a6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4b3639a6](https://forums.unrealengine.com/u/anonymous_user_4b3639a6)\
**Post date:** [May 24, 2017, 11:20am UTC](https://forums.unrealengine.com/t/attempting-to-replace-an-object-that-hasnt-been-fully-loaded-userwidget/393851/11 "2017-05-24T11:20:20Z")

</div>

Yeah its a custom class. But I didn’t override any UUserWidget methods.  
It just defines some virtual methods (Focus() Unfocus()).  
There are no module problems. Creating custom UserWidgets and showing them through code works fine.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [May 25, 2017, 2:14pm UTC](https://forums.unrealengine.com/t/attempting-to-replace-an-object-that-hasnt-been-fully-loaded-userwidget/393851/12 "2017-05-25T14:14:52Z")

</div>

I created a custom class based on UserWidget (MyUserWidget). I then added a pointer to my class in a custom actor class (`UMyUserWidget* WidgetTest;`). I did not get a when I compiled the code or added an instance of my class to the level and tried to play.

Please explain how you’re using your pointer in code as well as any other setup steps to help me reproduce the behavior locally. If possible, a sample project demonstrating the would be helpful as well.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4b3639a6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4b3639a6](https://forums.unrealengine.com/u/anonymous_user_4b3639a6)\
**Post date:** [May 26, 2017, 11:41pm UTC](https://forums.unrealengine.com/t/attempting-to-replace-an-object-that-hasnt-been-fully-loaded-userwidget/393851/13 "2017-05-26T23:41:59Z")

</div>

It’s actually an Actor which holds the Pointer to the custom widget class.  
I will try to create a clean project with that problem but at the moment I’m kinda busy

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [May 31, 2017, 7:22pm UTC](https://forums.unrealengine.com/t/attempting-to-replace-an-object-that-hasnt-been-fully-loaded-userwidget/393851/14 "2017-05-31T19:22:42Z")

</div>

Hey -

Have you had the chance to setup a sample project demonstrating your issue? If possible, can you provide the code for how you’re setting up your User Widget class as well as where it is being used by other classes?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4b3639a6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4b3639a6](https://forums.unrealengine.com/u/anonymous_user_4b3639a6)\
**Post date:** [June 1, 2017, 3:10pm UTC](https://forums.unrealengine.com/t/attempting-to-replace-an-object-that-hasnt-been-fully-loaded-userwidget/393851/15 "2017-06-01T15:10:37Z")

</div>

Unfortunately not.  
The Pointer is provided by my Custom Widgets.  
for example:  
If the Mouse hovers over a widget it tells my AUISystem that this widget should come into focus by calling AUISystem::FocusWidget(this);

The UFocusableWidget is the one which caused the. The first one is just the default WidgetClass which will be inherited by all my UserWidgets for this project

> **[//CustomWidget .h/\*\* \* CustomWidget should be derived from every UUserWidg -...](https://pastebin.com/uyuCEMya)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

There is no special magic going on in the functions. just a few calculations.

I don’t think we will come any further without spending more time in this problem 😕  
Unfortunately I’m really busy and I can’t provide the whole code because of NDA issues

Greetings

---

<div class="post-metadata">

**Author:** ![developer100](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@developer100](https://forums.unrealengine.com/u/developer100)\
**Post date:** [October 10, 2021, 9:16pm UTC](https://forums.unrealengine.com/t/attempting-to-replace-an-object-that-hasnt-been-fully-loaded-userwidget/393851/16 "2021-10-10T21:16:27Z")

</div>

This is old topic, but I had the same issue. In my case, it was caused by dynamically creating new objects (with NewObject in PostLoad), but not passing the RF\_Transient flag. Because of this, they are saved to the map, and after load, you try to create them again.
