There was conveniently a QString class member for me to access, and using that fixed the error. Thanks. When you said "returning a variable which is deleted/freed" I thought you meant the char *, but if Qstring was copying the string like it was supposed and then getting deleted, that wouldn't help. It makes me wonder why compiler issued a warning and not an error.
{
qDebug() << "DNumber as string";
char * buffer = new char[length()];
mReal->toFixPtString(buffer, mDecimalPlaces);
mValue = buffer;
delete buffer;
return mValue;
// the code runs and the warning dissapears, mValue persists
}
QString &DNumber::toString()
{
qDebug() << "DNumber as string";
char * buffer = new char[length()];
mReal->toFixPtString(buffer, mDecimalPlaces);
mValue = buffer;
delete buffer;
return mValue;
// the code runs and the warning dissapears, mValue persists
}
To copy to clipboard, switch view to plain text mode
Bookmarks