Problems migrating from UE4 to UE5. TSharedPtr is not casting correctly to C++ Pointer

Hello :slight_smile:

We are trying to migrate a project from UE4 to UE5. However, we are having the following problem during compilation time:

TSharedPtr<APlayerController> PlayerOwner; // we have it from somewhere else and it's working fine
// defaultWidget is SubClassOf<UMyUserWidget>
auto defaultWidgetInstance = CreateWidget<UMyUserWidget>(PlayerOwner, defaultWidget);

According to UE5 migration guide, https://docs.unrealengine.com/5.0/en-US/unreal-engine-5-migration-guide/, it says:

TObjectPtr variables also convert automatically to raw pointers when passed to functions or stored in local variables.

Nevertheless, this conversion is not happening automatically to a raw pointer, since we could fix it by doing the following:

auto defaultWidgetInstance = CreateWidget<UMyUserWidget>(&(*PlayerOwner), defaultWidget);

After doing this, then we see other similar problems in other parts of the project.

Are we doing something wrong? Did we skip an important step?

Thanks in advance :slight_smile: