My GetPlayerController just broke for unknown reason...

I am using very simple Show/Hide functions for my very simple Widget, both are working well, but it is not just working - it produces an error after PIE:

error

Here is one of those functions:

The other one for Show is pretty much the same, producing same kind of error.

As I already said, all those functions are working well, it is just an errors after the Play.

You see that in the log it is pointing out to the function on my screenshot #2? Well, guess what, it throw that error even when that particular function is never even called, checked with the Breakpoint because of growing paranoia.

It is all seems like some neat UE bug, because not just errors messages are incorrect, it is also untrue, because I’ve checked those PlayerControllers at the runtime, those are alright and valid. As I said, it all works well…

Found what was the issue.

Such an error happens consistently with the any Widget if it is was opened in the game, and you quit/crash the game with that widget active, which set to UI/UI and Game mode.

Only thing I can think of is that this method is called when the game shuts down, while the controller is being destroyed. That would explain why you get the error after PIE. Still, you say it happens even if the method is not called (and tested with breakpoints). It’s odd. Maybe it would be useful to have more of the log to see a call stack or see what the rest of the program was doing in the last moments.

It’s not happening for me on UE 5.2, all the way to 5.4.4. Tested on a main menu level with widgets opened constantly even during shutdown.

The direct fix to your error would be to do an IsValid check on the controller pointer before accessing the pointer. If your code is valid itself, then you would see no side effect. SetInputMode and following nodes would still execute when the controller is valid.

Yes, that makes sense now.

Not anymore, I changed it back days ago, now there is no Hide/Show functionality, replaced with straightforward Add To Viewport and Remove from Parent. After that, there is no such stuff every time I am exiting PIE. Since problem is gone, I am no longer bother that it remain unsolved.

It will just be one of those mysterious bugs which you never manage to figure out.

While was writing this, Checked your suggestion with the pre-check with IsValid, it worked lol, thanks: