diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -201,10 +201,12 @@ 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); + // 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; } @@ -214,7 +216,8 @@ // mutable, as it can be set to false by copying mutable bool relock; - void CopyFrom(const UnlockContext &rhs); + UnlockContext &operator=(const UnlockContext &) = default; + void CopyFrom(UnlockContext &&rhs); }; UnlockContext requestUnlock(); diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -470,7 +470,7 @@ } } -void WalletModel::UnlockContext::CopyFrom(const UnlockContext &rhs) { +void WalletModel::UnlockContext::CopyFrom(UnlockContext &&rhs) { // Transfer context; old object no longer relocks wallet *this = rhs; rhs.relock = false;