Skip to content
Snippets Groups Projects
Commit 4541fc86 authored by Matthias's avatar Matthias
Browse files

fix mem access error which caused the malformed string

GUIHelpers::Error::what() returned a char* to a temporary QByteArray which is invalid after leaving what()
parent 1f7292a9
No related branches found
No related tags found
No related merge requests found
...@@ -45,7 +45,7 @@ namespace GUIHelpers { ...@@ -45,7 +45,7 @@ namespace GUIHelpers {
Error::~Error() noexcept = default; Error::~Error() noexcept = default;
const char* Error::what() const noexcept { const char* Error::what() const noexcept {
return message.toLatin1().data(); return m_messageAsLatin1.data();
} }
void information(QWidget* parent, const QString& title, const QString& text, void information(QWidget* parent, const QString& title, const QString& text,
......
...@@ -26,7 +26,7 @@ class RealDataItem; ...@@ -26,7 +26,7 @@ class RealDataItem;
namespace GUIHelpers { namespace GUIHelpers {
class Error : public std::exception { class Error : public std::exception {
public: public:
explicit Error(const QString& message) noexcept : message(message) {} explicit Error(const QString& message) noexcept : m_messageAsLatin1(message.toLatin1()) {}
virtual ~Error() noexcept; virtual ~Error() noexcept;
Error(const Error&) = default; Error(const Error&) = default;
...@@ -37,7 +37,7 @@ public: ...@@ -37,7 +37,7 @@ public:
const char* what() const noexcept override; const char* what() const noexcept override;
private: private:
QString message; QByteArray m_messageAsLatin1;
}; };
void information(QWidget* parent, const QString& title, const QString& text, void information(QWidget* parent, const QString& title, const QString& text,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment