# Crash when using a slate widget with GetPlayerController

**URL:** <https://forums.unrealengine.com/t/crash-when-using-a-slate-widget-with-getplayercontroller/310282>\
**Category:** UI\
**Tags:** unreal-engine, Widget, question\
**Created:** [March 10, 2015, 9:52am UTC](https://forums.unrealengine.com/t/crash-when-using-a-slate-widget-with-getplayercontroller/310282 "2015-03-10T09:52:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_2db7ca80](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2db7ca80](https://forums.unrealengine.com/u/anonymous_user_2db7ca80)\
**Post date:** [March 10, 2015, 9:52am UTC](https://forums.unrealengine.com/t/crash-when-using-a-slate-widget-with-getplayercontroller/310282/1 "2015-03-10T09:52:13Z")

</div>

I have a widget which in one of the bound functions calls `GetPlayerController`. I have previously had this HUD added to the screen (which worked) but I tried adding it to a WidgetComponent. As soon as I do this, the editor crashes:

Access violation inside `UGameplayStatics::GetPlayerController` on line 38 (presumably now world [or no WorldContextObject])

This question seem related, but haven’t been resolved:

[Crash when spawning Actor with WidgetComponent](https://answers.unrealengine.com/questions/147302/crash-when-spawning-actor-with-widgetcomponent.html)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e729f54e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e729f54e](https://forums.unrealengine.com/u/anonymous_user_e729f54e)\
**Post date:** [March 10, 2015, 6:44pm UTC](https://forums.unrealengine.com/t/crash-when-using-a-slate-widget-with-getplayercontroller/310282/2 "2015-03-10T18:44:59Z")

</div>

Hello ,

I was unable to reproduce this issue on our end. I have a few questions for you that will help narrow down what issue it is that you are experiencing.

Quick questions:

1. What version of the engine are you using?
2. Can you reproduce this in a clean project?
3. If so, could you provide a detailed list of steps to reproduce this issue on our end?
4. Can you clarify to what actor it is that you are adding a widget comment to?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2db7ca80](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2db7ca80](https://forums.unrealengine.com/u/anonymous_user_2db7ca80)\
**Post date:** [March 11, 2015, 11:50am UTC](https://forums.unrealengine.com/t/crash-when-using-a-slate-widget-with-getplayercontroller/310282/3 "2015-03-11T11:50:57Z")

</div>

1. 4.6
2. Yes (for once!)
3. Steps:

- New project, create an actor blueprint and a blueprint widget
- In widget, add a text field and bind a function to it
- In the bound function call something like GetPlayerController() and call GetDisplayName on that and return that from the bound function
- Add a WidgetComponent to the actor
- Set the widget class to be the BP widget just created
- Observe the crash

1. The actor is just an empty blueprint deriving from Actor with the WidgetComponent in it.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e729f54e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e729f54e](https://forums.unrealengine.com/u/anonymous_user_e729f54e)\
**Post date:** [March 12, 2015, 11:53am UTC](https://forums.unrealengine.com/t/crash-when-using-a-slate-widget-with-getplayercontroller/310282/4 "2015-03-12T11:53:09Z")

</div>

Hello ,

I was able to reproduce this issue on our end in 4.6. However, after running the same test in 4.7.2 I have found that this issue has been fixed. Thank you for your time and information.

Make it a great day

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2db7ca80](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2db7ca80](https://forums.unrealengine.com/u/anonymous_user_2db7ca80)\
**Post date:** [March 12, 2015, 2:13pm UTC](https://forums.unrealengine.com/t/crash-when-using-a-slate-widget-with-getplayercontroller/310282/5 "2015-03-12T14:13:41Z")

</div>

Could you point me towards a commit that fixes it so I can integrate that in to our engine (we are not currently looking to upgrade to 4.7)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e729f54e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e729f54e](https://forums.unrealengine.com/u/anonymous_user_e729f54e)\
**Post date:** [March 13, 2015, 8:53pm UTC](https://forums.unrealengine.com/t/crash-when-using-a-slate-widget-with-getplayercontroller/310282/6 "2015-03-13T20:53:57Z")

</div>

Hello ,

I believe that this is the commit that you would be looking for. I hope that this helps.

[https://github.com/EpicGames/UnrealEngine/commit/48d435dfd39971d3c6f4f4c254551f8e93aac403](https://github.com/EpicGames/UnrealEngine/commit/48d435dfd39971d3c6f4f4c254551f8e93aac403)

Make it a great day
