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:
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?
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?
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.
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.
Yeah I know ^^
That should be its purpose. But something went wrong.
Do you maybe know why StaticDuplicateObject was called on the UPROPERTY UserWidget?
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.
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
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?
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.
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?
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.
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.
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
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?
The Pointer is provided by my Custom Widgets.
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
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
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.