QSharedMemoryLocker: add missing move SMFs and member- and ADL swap
This fixes clazy-rule-of-three (and -Wpeppe). The actual operations performed are copied from QMutexLocker. This code predates the public history. Pick-to: 6.7 Change-Id: Ieba73502187b32178ec2601e1902ac6b20a8e477 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> (cherry picked from commit a6f1779207958f25abeaa39b03d6459586bc7575) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
8d907213ef
commit
462088b115
@ -41,13 +41,22 @@ class QSharedMemoryPrivate;
|
||||
*/
|
||||
class QSharedMemoryLocker
|
||||
{
|
||||
|
||||
Q_DISABLE_COPY(QSharedMemoryLocker)
|
||||
public:
|
||||
Q_NODISCARD_CTOR QSharedMemoryLocker(QSharedMemory *sharedMemory) : q_sm(sharedMemory)
|
||||
{
|
||||
Q_ASSERT(q_sm);
|
||||
}
|
||||
|
||||
Q_NODISCARD_CTOR QSharedMemoryLocker(QSharedMemoryLocker &&other) noexcept
|
||||
: q_sm{std::exchange(other.q_sm, nullptr)}
|
||||
{}
|
||||
|
||||
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QSharedMemoryLocker)
|
||||
|
||||
void swap(QSharedMemoryLocker &other) noexcept
|
||||
{ qt_ptr_swap(q_sm, other.q_sm); }
|
||||
|
||||
inline ~QSharedMemoryLocker()
|
||||
{
|
||||
if (q_sm)
|
||||
@ -63,6 +72,9 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
friend void swap(QSharedMemoryLocker &lhs, QSharedMemoryLocker &rhs) noexcept
|
||||
{ lhs.swap(rhs); }
|
||||
|
||||
QSharedMemory *q_sm;
|
||||
};
|
||||
#endif // QT_CONFIG(systemsemaphore)
|
||||
|
Loading…
x
Reference in New Issue
Block a user