Hello,
I have a C++ UClass and inherited a BP from it. Another C++ class, which is a widget, not a UObject, has a pointer to an object of that UClass. When I manipulate it in the editor, it is fine. However, when I recompile the inherited BP while the widget is still open, the pointer that the widget owns becomes invalid and only when I close the window and re-open it or otherwise reconstruct the widget the pointer becomes valid again.
It appears that when recompiling, object references to objects of that class first become invalid while the compiler updates, and then get fixed again - with other UObjects. Since widgets (Slate) are not UObjects, my guess is that that pointer does not update its reference automatically because of it.
How do I tell my C++ system it needs to reconstruct after a BP compile? Or if there’s another, proper way, how do I fix this? Right now I have a raw pointer to that UObject, would using a TWeakObjectPtr help?
EDIT: I got more information now: the object that is being accessed while it is invalid isn’t a nullptr. The original class name of the BP class is “CameraEvent_C”, however the one being accessed is “REINST_CameraEvent_C” which seems like my assumption correct; the old object is supposed to be reinstanced, but something goes wrong, probably because the widget isn’t a UObject.
2nd EDIT: Wrapping the pointer as a TWeakObjectPtr results in the object being “STALE”, and if accessed, a nullptr.To clarify the question: How do I properly update references to UObjects of objects that aren’t UObjects, since compiling the BP of the latter results in reinstancing the objects, which seemingly doesn’t work with non-UObjects.