From 1d426e621cff1cb0a024f726dc5525e027d190aa Mon Sep 17 00:00:00 2001 From: Xavier Michelon Date: Mon, 6 Mar 2023 12:40:28 +0100 Subject: [PATCH] fix(GODT-2449): fix bug in Bridge-GUI's Exception::what(). --- .../bridgepp/bridgepp/Exception/Exception.cpp | 11 +++++++---- .../bridgepp/bridgepp/Exception/Exception.h | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/internal/frontend/bridge-gui/bridgepp/bridgepp/Exception/Exception.cpp b/internal/frontend/bridge-gui/bridgepp/bridgepp/Exception/Exception.cpp index a9179038..eeda30d6 100644 --- a/internal/frontend/bridge-gui/bridgepp/bridgepp/Exception/Exception.cpp +++ b/internal/frontend/bridge-gui/bridgepp/bridgepp/Exception/Exception.cpp @@ -26,9 +26,10 @@ namespace bridgepp { /// \param[in] what A description of the exception. /// \param[in] details The optional details for the exception. //**************************************************************************************************************************************************** -Exception::Exception(QString what, QString details) noexcept +Exception::Exception(QString qwhat, QString details) noexcept : std::exception() - , what_(std::move(what)) + , qwhat_(std::move(qwhat)) + , what_(qwhat_.toLocal8Bit()) , details_(std::move(details)) { } @@ -38,6 +39,7 @@ Exception::Exception(QString what, QString details) noexcept //**************************************************************************************************************************************************** Exception::Exception(Exception const &ref) noexcept : std::exception(ref) + , qwhat_(ref.qwhat_) , what_(ref.what_) , details_(ref.details_) { } @@ -48,6 +50,7 @@ Exception::Exception(Exception const &ref) noexcept //**************************************************************************************************************************************************** Exception::Exception(Exception &&ref) noexcept : std::exception(ref) + , qwhat_(ref.qwhat_) , what_(ref.what_) , details_(ref.details_) { } @@ -57,7 +60,7 @@ Exception::Exception(Exception &&ref) noexcept /// \return a string describing the exception //**************************************************************************************************************************************************** QString Exception::qwhat() const noexcept { - return what_; + return qwhat_; } @@ -65,7 +68,7 @@ QString Exception::qwhat() const noexcept { /// \return A pointer to the description string of the exception. //**************************************************************************************************************************************************** const char *Exception::what() const noexcept { - return what_.toLocal8Bit().constData(); + return what_.constData(); } diff --git a/internal/frontend/bridge-gui/bridgepp/bridgepp/Exception/Exception.h b/internal/frontend/bridge-gui/bridgepp/bridgepp/Exception/Exception.h index 9cde3e7d..ff565d23 100644 --- a/internal/frontend/bridge-gui/bridgepp/bridgepp/Exception/Exception.h +++ b/internal/frontend/bridge-gui/bridgepp/bridgepp/Exception/Exception.h @@ -31,7 +31,7 @@ namespace bridgepp { //**************************************************************************************************************************************************** class Exception : public std::exception { public: // member functions - explicit Exception(QString what = QString(), QString details = QString()) noexcept; ///< Constructor + explicit Exception(QString qwhat = QString(), QString details = QString()) noexcept; ///< Constructor Exception(Exception const &ref) noexcept; ///< copy constructor Exception(Exception &&ref) noexcept; ///< copy constructor Exception &operator=(Exception const &) = delete; ///< Disabled assignment operator @@ -42,7 +42,8 @@ public: // member functions QString details() const noexcept; ///< Return the details for the exception private: // data members - QString const what_; ///< The description of the exception. + QString const qwhat_; ///< The description of the exception. + QByteArray const what_; ///< The c-string version of the qwhat message. Stored as a QByteArray for automatic lifetime management. QString const details_; ///< The optional details for the exception. };