[4.2] Getting GameState from World returns null

The following code which worked in 4.1.1 now returns NULL in 4.2:

AGameGameState* gameState = world->GetGameState<AGameGameState>();

I have solved my problem, which was using an invalid UWorld pointer to generate a Slate widget from a static function. I have used the example in Shooter Game 4.2, and used FLocalPlayerContext to get a proper pointer to the world to get the game state.

//In HUD
APlayerController* pc = GetOwningPlayerController();
FLocalPlayerContext context(pc);

// pass this to static Slate widget creation function and do
UWorld* world = Context.GetWorld();
AGameGameState* gameState = world->GetGameState<AGameGameState>();

//gameState is no longer NULL