Make ImplicitSharingPtr constructor from data pointer explicit #115476

Merged
Lukas Tönne merged 1 commits from LukasTonne/blender:implicit-sharing-ptr-ctor into main 2023-11-27 15:53:38 +01:00

1 Commits

Author SHA1 Message Date
Lukas Tönne 3e20fac450 Make ImplicitSharingPtr constructor from data pointer explicit.
buildbot/vexp-code-patch-coordinator Build done. Details
The ImplicitSharingPtr has an implicit constructor for raw pointers.
This has unintended effects when comparing an ImplicitSharingPtr to a
raw pointer: The raw pointer is implicitly converted to the shared
pointer (without change in refcount) and when going out of scope will
decrement user count, eventually freeing the data.

Conversion from raw pointer to shared pointer should not happen
implicitly. The constructor is made explicit now. This requires a little
more boilerplate when constructing a sharing pointer. A special
constructor for the nullptr is added so comparison with nullptr can
still happen without writing out a constructor.
2023-11-27 13:50:22 +01:00