show correct exceptions: fix exception memory access bug

master
Marc Wäckerlin 6 years ago
parent 195a07bcbe
commit 657c67fcf4
  1. 4
      src/exceptions.hxx

@ -16,7 +16,8 @@ class Exception: public std::exception {
Exception(QString w): _what(w) {} Exception(QString w): _what(w) {}
~Exception() throw() {} ~Exception() throw() {}
const char* what() const throw() { const char* what() const throw() {
return _what.toStdString().c_str(); _bytes = _what.toUtf8();
return _bytes.data();
} }
void line(int linenr) { void line(int linenr) {
if (linenr>0) _what=QString::number(linenr)+" "+_what; if (linenr>0) _what=QString::number(linenr)+" "+_what;
@ -25,6 +26,7 @@ class Exception: public std::exception {
if (filename.size()) _what=filename+":"+_what; if (filename.size()) _what=filename+":"+_what;
} }
protected: protected:
QByteArray _bytes;
QString _what; QString _what;
}; };

Loading…
Cancel
Save