During termination my program causes access violation trying to read at nullptr when I call
QTextStream(stdout) << ... << endl;
from within my global object's destructor.
The problem is here:
codec = QTextCodec::codecForLocale();
Since here you just assume codec is not nullptr and access it like this:
QByteArray data = codec->fromUnicode(writeBuffer.data(), writeBuffer.size(), &writeConverterState);
but QTextCodec::codecForLocale() may have returned nullptr if some internal Qt global data is already destroyed (destroyed before my global object) and if this is the case codec stays nullptr.