show correct exceptions: fix exception memory access bug

This commit is contained in:
Marc Wäckerlin
2018-11-14 11:01:08 +01:00
parent 195a07bcbe
commit 657c67fcf4

View File

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