Why do I get CDO Errors?

About why the error happens… The
ConstructorHelpers::FClassFinder() is
a static function that is supposed to
run only in the constructor.

Yes. I assumed that running FClassFinder from a function that is directly called from the constructor would count as the same. After all, I can do this with the FObjectFinderOptional() so it made sense to me that the FClassFinder could do this as well (but apparently not). After all, it works. It’s just that it throws the CDO errors even when there is no ‘real error’. Maybe it would bug out the CDO for the class but in the case of pure C++ classes and not having a blueprint ever inherit from it, should not cause any problems. Maybe if you explicitly try to retrieve the CDO values through C++ but that is rare. Therefor I still believe that the CDO errors for my particular case should not have been thrown. At the most they should have been warnings.
I read: Creating Objects in Unreal Engine | Unreal Engine 5.3 Documentation

What I guess that happens is:

  • FClassFinder must be inside the constructor, but it will still work when placed outside of it.
  • The CDO errors from the FClassFinder are queued in some list somewhere and all thrown together as 1 messagebox. Therefor it does not show me the error while stepping through it.
  • The CDO errors are thrown even if the FClassFinder was successful in retrieving the class from outside of the constructor. Maybe there is some unknown side-effect somewhere but I still suspect a minor UE4 bug here.

Oh I see so I don’t even need all those nullptr checks. Well yes thanks that would simplify it even more :). That no longer requires a function indeed.