Editor Abort in ConstructorHelpers::CheckIfIsInConstructor

The following code causes the editor to abort when you Play. This is on Mac OS X 10.10.3, XCode 6.3.1, UE4 4.7.6. I open the Editor from XCode because of another bug that I think has been reported.

    TSubclassOf<class VehicleBlueprint> MyVehicleBlueprint;
    static ConstructorHelpers::FObjectFinder<UBlueprint> VehicleBlueprint(TEXT("Blueprint'/Game/Vehicle/VehicleBlueprint.VehicleBlueprint'"));
    if (VehicleBlueprint.Object){
        MyVehicleBlueprint = (UClass*)VehicleBlueprint.Object->GeneratedClass;
    }

Is this a real bug or a result of how I’m running UE4. I have to start it from XCode or blueprints are unable to see the Classes, Functions, and Properties specified with Blueprint specifiers. This was pointed out in another question (hopefully a bug report but I don’t remember, something about Hot Reload not updating the editor). But that is why I am starting the editor in an unusual manner. I took this code pretty much verbatim from other posts on the subject of getting an object to a blueprint that is to be spawned. I was trying it out at the time of the abort.

I approached this in a completely different manner using code provided in another answer. By placing the code in my GameMode class, it worked great, I was able to spawn the vehicle blueprint. I moved this code to my PlayerController class and once again ended up with an editor abort in the same routine. Is it invalid to spawn pawns in the PlayerController class? If not, I have an alternate example I can provide that is working if not done in the PlayerController.

Hey -

When you mention running UE4 from XCode are you referring to running in debug mode? Aslo, where is the code you’re using being called at? Is it inside of a class constructor or elsewhere? What kind of class are you using (actor, pawn, character, etc)? If you can reproduce the error in a new project please list the steps that caused the bug.

Cheers

Yes, I must start the editor from XCode in debug mode in order to give blueprints visibility into my public/blueprintable C++ routines. I can search for the bug report on this if you need. It was Mac specific, and I followed his workaround to get things functional. To reproduce how I am starting it, I select the ProjectEditor scheme in the pulldown at the top of the XCode dialog, then press the play (right block arrow icon) to launch Unreal. Doing so, causes any C++ variables or routines specifying visibility to blueprints to work. Otherwise they don’t don’t exist.

It was not in the constructor, I put it in BeginPlay. The class was a clone of the VehicleBlueprint from the driving game example. It was modified slightly but just the models and textures. It’s parent class shows as WheeledVehicle.

I may be able to set up a separate project for this, and reproduce. It will take some free time to do that. I’m working around it by not placing FObjectFinder calls in the PlayerController.

Hey -

Calling FObjectFinder outside of the constructor is not meant to work. This is because FObjectFinder adds all objects it finds/loads to the root set and those objects won’t ever be garbage collected. Moving the code segment into the constructor should stop the editor crashing when the call is made.

Cheers

Thanks, that explains that. I did have it in the constructor in GameMode.