Changing a class method return value crashes UE4 when hot reloading

  1. Create a C++ class and create a method with any return type (can probably be void as well).
  2. Compile the code in visual studio and open the project in UE4
  3. Create a blueprint which calls this method, but don’t make use of the return type
  4. Go back to C++ code and change the method return type to something else
  5. Use UE4 to recompile the code
  6. CRASH!

Expected response: The UE4 blueprint editor refreshes the method output node to the appropriate type.

Hey -

In 4.6.1 and the 4.7 preview I created a code class based on actor and added a simple method to it:

.h
UPROPERTY(BlueprintCallable, Category = Testing)
int32 CrashTest();
.cpp
int32 AMyActor::CrashTest()
{
return 45;
}

After compiling and creating a blueprint I changed the return type from int32 to float and compiled inside the editor. I noticed that the return pin did not change from an integer to a float, however I did not crash. Which version of the engine are you working in where you crashed when hot reloading in the editor?

I am using version 4.6.1

In my attempt to reproduce the error, I had another slightly unrelated crash:

  1. Compile and run my game
  2. Open up a class, while the game is running, and add a new method in the .H file and .CPP file:

.H:
UFUNCTION(BlueprintCallable, Category=DebugTest)
float Test();

.CPP:
float MyClass::Test()
{
return 1.2f;
}

  1. Within the UE4 editor, compile the change
  2. Attempts compile for 10 seconds, result: Crash

I kind of expected this and it’s probably a known issue / limitation of hot compiling.

Just to verify that I could reproduce the original crash, I tried it again and it crashes. Here’s my steps:

  1. Take an existing class within my game and add the above code to it.
  2. Within the level blueprint I make a call to the Test function and use the Print node to print the output to the screen on every tick function.
  3. I run the blueprint and it prints 1.2 on the screen repeatedly. So far, so good.
  4. I go back into the code and change the return value from a float to uint8, change the returned value to 15, then recompile. This causes a crash.
    Note: I had the level blueprint open at the time. It may or may not matter.
    Here is the blueprint I used. Note that there is a cast node right by the print string. Switching the function return value should break the link on recompile, but it crashes instead.

When I recompile the whole game and run it again, there are no issues. Maybe its a similar limitation to the first issue?

Hey -

Sorry for the delayed response. Looking at your workflow, where you changed “float” to “uint8” appears to be the issue. uint8 is not a data type supported by blueprints. You should be able to use int32 instead for integer values. Note that the pin for the return value in blueprints won’t update from float to int until the editor is closed and reopened (UE-7646).

Cheers