Unable to get Stroke class

I’m currently in the saving part of the UE4 VR C++ course, and I’m having some trouble with serializing the stroke. I keep getting this error message when trying to load:
LogSpawn: Warning: SpawnActor failed because no class was specified

Serializing:

FStrokeState AStroke::SerializeToStruct() const
{
	FStrokeState State;
	State.Class = GetClass();
	State.ControlPoints = ControlPoints;

	return State;
}

De-serializing:

AStroke* AStroke::DeserializeAndSpawnFromStruct(UWorld* World, const FStrokeState& StrokeState)
{
	AStroke* Stroke = World->SpawnActor<AStroke>(StrokeState.Class);
	for (FVector ControlPoint : StrokeState.ControlPoints)
	{
		Stroke->Update(ControlPoint);
	}
	return Stroke;
}

Any help would be appreciated!

Hello,

I have not taken this course but from what I can see, it seems like the Stroke class is null, have you by any chance suppose to assign the class to spawn from the blueprint? In order to get rid of the error message you can simply do a check before spawning.

if(StrokeState.Class == nullptr)
{
   return nullptr;
}

I was able to trace it back to the function that called AStroke::DeserializeAndSpawnFromStruct.

void UPainterSaveGame::DeserializeToWorld(UWorld* World)
{
	for (TActorIterator<AStroke> StrokeItr(World); StrokeItr; ++StrokeItr)
	{
		StrokeItr->Destroy();
	}

	for (FStrokeState StrokeState : Strokes)
	{
		AStroke::DeserializeAndSpawnFromStruct(World, StrokeState);
	}
}

It appears that the StrokeState in the second for loop is an empty struct.

But at this stage of my code, the class is filled in, but the control points are not:

void UPainterSaveGame::SerializeFromWorld(UWorld* World)
{
	Strokes.Empty();
	for (TActorIterator<AStroke> StrokeItr(World); StrokeItr; ++StrokeItr)
	{
		FStrokeState StrokeState = StrokeItr->SerializeToStruct();
		Strokes.Add(StrokeState);
	}
}

Sounds like they aren’t getting reloaded from the save file. How are they setup in the header?