Skip to content

Commit 5474253

Browse files
committed
Merge bitcoin-core#711: refactor: Disable unused special members functions in UnlockContext
9fa43b5 refactor: Disable unused special members functions in `UnlockContext` (Hennadii Stepanov) Pull request description: Also `UnlockContext::valid` and `UnlockContext::relock` are `const` now. ACKs for top commit: achow101: ACK 9fa43b5 john-moffett: ACK 9fa43b5 furszy: ACK 9fa43b5 Tree-SHA512: 6d9fa8208676b9bd5d85b73cb2d3136e7f28ef59e68ee34915ec598458868e302a80b9ef1384c0bf7a4c42f936830c3add9662ca0bae73860a55a25cc374b699
2 parents 5ecd14a + 9fa43b5 commit 5474253

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

src/qt/walletmodel.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -477,13 +477,6 @@ WalletModel::UnlockContext::~UnlockContext()
477477
}
478478
}
479479

480-
void WalletModel::UnlockContext::CopyFrom(UnlockContext&& rhs)
481-
{
482-
// Transfer context; old object no longer relocks wallet
483-
*this = rhs;
484-
rhs.relock = false;
485-
}
486-
487480
bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
488481
{
489482
CCoinControl coin_control;

src/qt/walletmodel.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class WalletModel : public QObject
111111
bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString());
112112
bool changePassphrase(const SecureString &oldPass, const SecureString &newPass);
113113

114-
// RAI object for unlocking wallet, returned by requestUnlock()
114+
// RAII object for unlocking wallet, returned by requestUnlock()
115115
class UnlockContext
116116
{
117117
public:
@@ -120,18 +120,16 @@ class WalletModel : public QObject
120120

121121
bool isValid() const { return valid; }
122122

123-
// Copy constructor is disabled.
123+
// Disable unused copy/move constructors/assignments explicitly.
124124
UnlockContext(const UnlockContext&) = delete;
125-
// Move operator and constructor transfer the context
126-
UnlockContext(UnlockContext&& obj) { CopyFrom(std::move(obj)); }
127-
UnlockContext& operator=(UnlockContext&& rhs) { CopyFrom(std::move(rhs)); return *this; }
125+
UnlockContext(UnlockContext&&) = delete;
126+
UnlockContext& operator=(const UnlockContext&) = delete;
127+
UnlockContext& operator=(UnlockContext&&) = delete;
128+
128129
private:
129130
WalletModel *wallet;
130-
bool valid;
131-
mutable bool relock; // mutable, as it can be set to false by copying
132-
133-
UnlockContext& operator=(const UnlockContext&) = default;
134-
void CopyFrom(UnlockContext&& rhs);
131+
const bool valid;
132+
const bool relock;
135133
};
136134

137135
UnlockContext requestUnlock();

0 commit comments

Comments
 (0)