Calling a code defined function in blueprints that returns a TWeakObjectPtr causes a crash.
1. Open UE4 Editor
2. Add code to project based on Actor (AMyActor)
3. In the header file add the following:
UFUNCTION(BlueprintCallable, Category="test")
TWeakObjectPtr<AActor> ReturnWeakObject();
4. In the source file add the following:
TWeakObjectPtr<AActor> AMyActor::ReturnWeakObject()
{
auto Actor = GetWorld()->SpawnActor<AStaticMeshActor>();
return TWeakObjectPtr<AActor>(Actor);
}
5. Compile
6. Create blueprint based on AMyActor
7. Enable Input on Begin Play
8. Add WeakObjectPtr node and connect to key press event (T)
9. PIE and press T
Result:
Editor immediately crashes
Head over to the existing Questions & Answers thread and let us know what's up.
| 0 |
| Component | UE - Gameplay - Blueprint |
|---|---|
| Affects Versions | 4.7.3, 4.8 |
| Target Fix | 4.8 |
| Fix Commit | 2499396 |
|---|
| Created | Mar 20, 2015 |
|---|---|
| Resolved | Apr 2, 2015 |
| Updated | Apr 27, 2018 |