summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qdatastream.cpp
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2023-09-28 15:52:06 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2023-10-22 18:58:43 +0200
commitbb23a05905d7dc0e416a646e40592436daa939f2 (patch)
tree5a681dc91deb316b2986e8a6eeb3c28d6ca54b19 /src/corelib/serialization/qdatastream.cpp
parentf2e19d37de36a2dd7bea8710d4582414f3fa175b (diff)
QWeakPointer: deprecate its relational operators
They're fundamentally broken and should never ever be used. * op==(weak, weak) is heterogeneous, but at the same time it's unconstrained (!), may trigger UB (!) by doing a static_cast to a type which isn't the actual type of the pointee, and may outright crash (!) if the pointee has been deleted and there's virtual inheritance. * op==(weak, strong) compares the control blocks, i.e. does "owner_equal" comparison, not pointer comparison. Now QSP doesn't have support for aliasing, so the pointers stored by the smart pointers themselves always point at the owner object. Yet: given a QSharedPointer<T> that is the last owning pointer to T and a QWeakPointer<T> that tracks it, if one resets the shared pointer, then op==(wp, sp) will yield false (wp still points to the control block, sp does not), but op==(wp.lock(), sp) will yield true (both shared pointers are null). That doesn't make any sense. I'm leaving op==(wp, std::nullptr_t) in as a shorthand to check if the weak pointer is expired, but might deprecate that as well in a future commit. [ChangeLog][QtCore][QWeakPointer] The (in)equality operators of QWeakPointer have been deprecated. Always upgrade a QWeakPointer to a QSharedPointer (for instance, via lock()) before doing a comparison. Change-Id: Ia2f5f5e9e5558e1558b6084542532515c80b78b0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/serialization/qdatastream.cpp')
0 files changed, 0 insertions, 0 deletions