From 7927fe065f50b3f16d305b2f38923e1e832515e5 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 21 Mar 2017 12:45:04 -0400 Subject: [PATCH] Fix move constructors and assignments of AudacityException classes --- src/AudacityException.cpp | 1 + src/FileException.h | 5 +++++ src/InconsistencyException.h | 11 +++++++++-- src/UserException.h | 2 ++ src/blockfile/NotYetAvailableException.cpp | 2 +- src/blockfile/NotYetAvailableException.h | 4 +--- 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/AudacityException.cpp b/src/AudacityException.cpp index 84451970a..46504d4cc 100644 --- a/src/AudacityException.cpp +++ b/src/AudacityException.cpp @@ -31,6 +31,7 @@ MessageBoxException &MessageBoxException::operator = ( MessageBoxException &&tha { caption = that.caption; if ( this != &that ) { + AudacityException::operator=( std::move(that) ); if (!moved) wxAtomicDec( sOutstandingMessages ); diff --git a/src/FileException.h b/src/FileException.h index 8cf1dfd6f..ef8f5e506 100644 --- a/src/FileException.h +++ b/src/FileException.h @@ -27,8 +27,13 @@ public: FileException(FileException&& that) : MessageBoxException(std::move(that)) + , cause{ that.cause } + , fileName{ that.fileName } + , renameTarget{ that.renameTarget } {} + FileException& operator= (FileException&&) PROHIBITED; + ~FileException() override; protected: diff --git a/src/InconsistencyException.h b/src/InconsistencyException.h index fdc0741bd..065919eff 100644 --- a/src/InconsistencyException.h +++ b/src/InconsistencyException.h @@ -27,11 +27,18 @@ public: InconsistencyException(InconsistencyException&& that) : MessageBoxException(std::move(that)) + , func{ that.func } + , file{ that.file } + , line{ that.line } {} InconsistencyException &operator = (InconsistencyException &&that) { - if (this != &that) - operator= (std::move(that)); + if (this != &that) { + MessageBoxException::operator= (std::move(that)); + func = that.func; + file = that.file; + line = that.line; + } return *this; } diff --git a/src/UserException.h b/src/UserException.h index cf3989162..e59b881cc 100644 --- a/src/UserException.h +++ b/src/UserException.h @@ -25,6 +25,8 @@ public: : AudacityException{ std::move( that ) } {} + UserException& operator= (UserException&&) PROHIBITED; + ~UserException() override; void DelayedHandlerAction() override; diff --git a/src/blockfile/NotYetAvailableException.cpp b/src/blockfile/NotYetAvailableException.cpp index 81ebcc785..656c606a9 100644 --- a/src/blockfile/NotYetAvailableException.cpp +++ b/src/blockfile/NotYetAvailableException.cpp @@ -23,6 +23,6 @@ wxString NotYetAvailableException::ErrorMessage() const { return wxString::Format( _("This operation cannot be done until importation of %s completes."), - mFileName.GetFullName() + fileName.GetFullName() ); } diff --git a/src/blockfile/NotYetAvailableException.h b/src/blockfile/NotYetAvailableException.h index c54c262e7..d961bcec7 100644 --- a/src/blockfile/NotYetAvailableException.h +++ b/src/blockfile/NotYetAvailableException.h @@ -21,14 +21,12 @@ public: : FileException{ Cause::Read, fileName } {} NotYetAvailableException(NotYetAvailableException &&that) : FileException( std::move( that ) ) {} + NotYetAvailableException& operator= (NotYetAvailableException&&) PROHIBITED; ~NotYetAvailableException(); protected: std::unique_ptr< AudacityException > Move() override; wxString ErrorMessage() const override; - -private: - wxFileName mFileName; }; #endif