Skip to content

Replace raw uobject ptrs with TObjectPtr for UPROPERTY#454

Merged
getnamo merged 1 commit intogetnamo:mainfrom
rohitsutreja:replace-raw-uobject-pointers-with-TObjectPtr-for-UPROPERTY
May 15, 2025
Merged

Replace raw uobject ptrs with TObjectPtr for UPROPERTY#454
getnamo merged 1 commit intogetnamo:mainfrom
rohitsutreja:replace-raw-uobject-pointers-with-TObjectPtr-for-UPROPERTY

Conversation

@rohitsutreja
Copy link
Copy Markdown
Contributor

I have replaced Raw UObject pointers with TObjectPtr<> when used as UPROPERTY().

@rohitsutreja
Copy link
Copy Markdown
Contributor Author

fixes #453

@getnamo
Copy link
Copy Markdown
Owner

getnamo commented May 15, 2025

Have you tested your fixes and saw no regression?

@rohitsutreja
Copy link
Copy Markdown
Contributor Author

I have just replaced raw UObject pointers with TObjectPtr. I did this because for me Code was not compiling without it. After doing this code is compiling successfully.

I don't think it can cause any problems for engine version 5.0+.

Are there any test cases which I need to run?

@getnamo
Copy link
Copy Markdown
Owner

getnamo commented May 15, 2025

What platform are you compiling for? UObject* is perfectly valid in 5.5 and shouldn't throw an error

@rohitsutreja
Copy link
Copy Markdown
Contributor Author

Actually there is NativePointerMemberBehaviorOverride property which we can set in Target.cs file, The project I am working in has set it to Disallow. So In my project UHT throws error if raw pointers are used as member variables.

Also Epic recommends to use TObjectPtr too.

@getnamo
Copy link
Copy Markdown
Owner

getnamo commented May 15, 2025

From a quick read it appears to only modify editor behavior by tracking access, my guess is for easier debugging in editor modes, but serializes the same as raw ptrs. Seems harmless enough to merge.

@getnamo getnamo merged commit 27dec04 into getnamo:main May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants