Skip to content

Commit 0b09a57

Browse files
committed
Give WalletModel::UnlockContext move semantics
1 parent 79046d5 commit 0b09a57

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/qt/walletmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ WalletModel::UnlockContext::~UnlockContext()
482482
}
483483
}
484484

485-
void WalletModel::UnlockContext::CopyFrom(const UnlockContext& rhs)
485+
void WalletModel::UnlockContext::CopyFrom(UnlockContext&& rhs)
486486
{
487487
// Transfer context; old object no longer relocks wallet
488488
*this = rhs;

src/qt/walletmodel.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,18 @@ class WalletModel : public QObject
194194

195195
bool isValid() const { return valid; }
196196

197-
// Copy operator and constructor transfer the context
198-
UnlockContext(const UnlockContext& obj) { CopyFrom(obj); }
199-
UnlockContext& operator=(const UnlockContext& rhs) { CopyFrom(rhs); return *this; }
197+
// Copy constructor is disabled.
198+
UnlockContext(const UnlockContext&) = delete;
199+
// Move operator and constructor transfer the context
200+
UnlockContext(UnlockContext&& obj) { CopyFrom(std::move(obj)); }
201+
UnlockContext& operator=(UnlockContext&& rhs) { CopyFrom(std::move(rhs)); return *this; }
200202
private:
201203
WalletModel *wallet;
202204
bool valid;
203205
mutable bool relock; // mutable, as it can be set to false by copying
204206

205-
void CopyFrom(const UnlockContext& rhs);
207+
UnlockContext& operator=(const UnlockContext&) = default;
208+
void CopyFrom(UnlockContext&& rhs);
206209
};
207210

208211
UnlockContext requestUnlock();

0 commit comments

Comments
 (0)