On 12.11.2015 23:38, Thiago Macieira wrote:
On Thursday 12 November 2015 23:05:37 Igor Mironchik wrote:
Hi folks,
Is it a bug or feature?
First of all, allocating memory when throwing exceptions is bad practice.
Avoid it by redesigning your code.
Can you, please, explain why allocating memory when throwing exception
is bad practice? Or just can you give a link on any article about this
question.... Thank you.
TextFileViewException::TextFileViewException( const QString & what )
: std::runtime_error( what.toLocal8Bit() )
, m_what( what )
{
}
Look at this line:
std::runtime_error( what.toLocal8Bit() )
std::runtime_error() constructs from QByteArray... How it is possible?
Because toLocal8Bit() returns a QByteArray and QByteArray has an operator
const char*(). Why would it not be possible?
Do note that it compiles, but it's probably incorrect because
std::runtime_error will probably be carrying a dangling pointer.
Like I said, you should redesign so you don't allocate memory when throwing
exceptions.
Thank you, I understood. Just interesting why Qt 5.5.1 on Windows
compiled without QT_NO_CAST_FROM_BYTEARRAY and on Linux with this one?
That is why I was a little confused... :)
--
Best Regards,
Igor Mironchik.
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest