[Closed] What's the difference between using TWeakObjectPtr or using UObject*
What's the difference between using
asked May 27 '14 at 02:35 PM in C++ Programming
The question has been closed Jun 15 '14 at 03:35 PM by undercover for the following reason:
The question is answered, right answer was accepted
There's a Huge Difference, One Will Always Crash
There's a huge game-breaking difference between your two examples!
This will never crash
The below code is guaranteed to crash every single time based on how you've written in it
reason = you are de-referencing a pointer that is pointing to nothing (dereference is the -> operator)
IsValidLowLevel is not meant to be used for verifying the pointer, it is for verifying the integrity of the UObject after it is already known to exist, but might have been deleted recently. See below for how you can verify the pointer itself.
f using raw c++ pointers, you can just do this
The above using raw C++ pointers, and the example using .IsValid() are the two cases that are equivalent, and both are safe.
Why is this such a big deal?
Whether you understand this difference properly is what makes your game crash to desktop constantly, or run stable all the time (minus any infinite while loops hee hee) :)
Both of the options that you mentioned perform the same essential function. However, in general
answered May 27 '14 at 07:15 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here