QWeakPointer: mark lock() [[nodiscard]]
The lock() function, added for std::weak_ptr compatibility, sounds like QMutex::lock(), but is, in fact, a const function. QUIP-0019 says such functions must be marked [[nodiscard]]. For symmetry, also mark toStrongRef() and toWeakRef() as [[nodiscard]]. Change-Id: Ifb6e447d2cd96fedd9a78decdfac6bc57c1d282a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 81d357ff8a7af8704ba5657caef04f28e7099625) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
850e926841
commit
1a6e1660b1
@ -383,7 +383,7 @@ public:
|
||||
|
||||
inline void clear() { QSharedPointer copy; swap(copy); }
|
||||
|
||||
QWeakPointer<T> toWeakRef() const;
|
||||
[[nodiscard]] QWeakPointer<T> toWeakRef() const;
|
||||
|
||||
template <typename... Args>
|
||||
static QSharedPointer create(Args && ...arguments)
|
||||
@ -615,9 +615,9 @@ public:
|
||||
|
||||
inline void clear() { *this = QWeakPointer(); }
|
||||
|
||||
inline QSharedPointer<T> toStrongRef() const { return QSharedPointer<T>(*this); }
|
||||
[[nodiscard]] QSharedPointer<T> toStrongRef() const { return QSharedPointer<T>(*this); }
|
||||
// std::weak_ptr compatibility:
|
||||
inline QSharedPointer<T> lock() const { return toStrongRef(); }
|
||||
[[nodiscard]] QSharedPointer<T> lock() const { return toStrongRef(); }
|
||||
|
||||
template <class X>
|
||||
bool operator==(const QWeakPointer<X> &o) const noexcept
|
||||
|
Loading…
x
Reference in New Issue
Block a user