aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMeshCollider <dobsonsa68@gmail.com>2019-05-20 00:13:31 +1200
committerMeshCollider <dobsonsa68@gmail.com>2019-05-20 00:13:53 +1200
commit72634244580dc2e3c630ee27e47587080d064b68 (patch)
tree964bb82bd7a44a652b0fce9041192aefd3f7d7e3 /src
parent7110d455eb51e78e09f43fabf0b1630ae997d898 (diff)
parent0b09a57aec4c56712711585a4314d73d4d9b6877 (diff)
downloadbitcoin-72634244580dc2e3c630ee27e47587080d064b68.tar.xz
Merge #16001: Give WalletModel::UnlockContext move semantics
0b09a57ae Give WalletModel::UnlockContext move semantics (Pieter Wuille) Pull request description: WalletModel::UnlockContext seems to implement "move upon copy" semantics; with C++11 this can be done more safely using move semantics (making attempts to actually copy fail instead). Not a big deal if this isn't worth review time. ACKs for commit 0b09a5: Empact: utACK https://github.com/bitcoin/bitcoin/pull/16001/commits/0b09a57aec4c56712711585a4314d73d4d9b6877 jonasschnelli: utACK 0b09a57aec4c56712711585a4314d73d4d9b6877 jb55: utACK 0b09a57aec4c56712711585a4314d73d4d9b6877 Tree-SHA512: f827856586afd03666c2d9f50320776afb3dd511ac1bcd293b330f015acd1588551b163dccc97b1351301e3295f4c74d90e5754bcee89faeadf6437d7db165c8
Diffstat (limited to 'src')
-rw-r--r--src/qt/walletmodel.cpp2
-rw-r--r--src/qt/walletmodel.h11
2 files changed, 8 insertions, 5 deletions
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index fd392b7cf7..a2b295df21 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -482,7 +482,7 @@ WalletModel::UnlockContext::~UnlockContext()
}
}
-void WalletModel::UnlockContext::CopyFrom(const UnlockContext& rhs)
+void WalletModel::UnlockContext::CopyFrom(UnlockContext&& rhs)
{
// Transfer context; old object no longer relocks wallet
*this = rhs;
diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h
index b123befbb4..54428aec08 100644
--- a/src/qt/walletmodel.h
+++ b/src/qt/walletmodel.h
@@ -194,15 +194,18 @@ public:
bool isValid() const { return valid; }
- // Copy operator and constructor transfer the context
- UnlockContext(const UnlockContext& obj) { CopyFrom(obj); }
- UnlockContext& operator=(const UnlockContext& rhs) { CopyFrom(rhs); return *this; }
+ // Copy constructor is disabled.
+ UnlockContext(const UnlockContext&) = delete;
+ // Move operator and constructor transfer the context
+ UnlockContext(UnlockContext&& obj) { CopyFrom(std::move(obj)); }
+ UnlockContext& operator=(UnlockContext&& rhs) { CopyFrom(std::move(rhs)); return *this; }
private:
WalletModel *wallet;
bool valid;
mutable bool relock; // mutable, as it can be set to false by copying
- void CopyFrom(const UnlockContext& rhs);
+ UnlockContext& operator=(const UnlockContext&) = default;
+ void CopyFrom(UnlockContext&& rhs);
};
UnlockContext requestUnlock();