summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-10-02 17:38:40 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-10-03 11:47:14 +0200
commitc441e2cc476c76496f037f0b5f4bd4bfdd82c727 (patch)
tree0eacfd87607098b37ea664f2c5ce010043b1d8a7 /src
parent257d5888e8086e6fcea87f68bb06feb56cd830d6 (diff)
QMacKeyValueObserver: code tidies
Fix the constructors and the signature of swap(). Change-Id: Ib294bb2c054510170b166b5c8bd3180d22177efc Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qcore_mac_p.h17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h
index 02ea0aabdc..cb00fe0b24 100644
--- a/src/corelib/kernel/qcore_mac_p.h
+++ b/src/corelib/kernel/qcore_mac_p.h
@@ -367,7 +367,7 @@ class Q_CORE_EXPORT QMacKeyValueObserver
public:
using Callback = std::function<void()>;
- QMacKeyValueObserver() {}
+ QMacKeyValueObserver() = default;
#if defined( __OBJC__)
// Note: QMacKeyValueObserver must not outlive the object observed!
@@ -381,13 +381,13 @@ public:
QMacKeyValueObserver(const QMacKeyValueObserver &other);
- QMacKeyValueObserver(QMacKeyValueObserver &&other) { swap(other, *this); }
+ QMacKeyValueObserver(QMacKeyValueObserver &&other) noexcept { swap(other); }
~QMacKeyValueObserver() { removeObserver(); }
QMacKeyValueObserver &operator=(const QMacKeyValueObserver &other) {
QMacKeyValueObserver tmp(other);
- swap(tmp, *this);
+ swap(tmp);
return *this;
}
@@ -399,13 +399,14 @@ public:
void removeObserver();
-private:
- void swap(QMacKeyValueObserver &first, QMacKeyValueObserver &second) {
- std::swap(first.object, second.object);
- std::swap(first.keyPath, second.keyPath);
- std::swap(first.callback, second.callback);
+ void swap(QMacKeyValueObserver &other) noexcept
+ {
+ qSwap(object, other.object);
+ qSwap(keyPath, other.keyPath);
+ qSwap(callback, other.callback);
}
+private:
#if defined( __OBJC__)
void addObserver(NSKeyValueObservingOptions options);
#endif