From f2a40fa07123748ece2fc93790345379f15ef07f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 14 Apr 2014 15:31:06 -0700 Subject: Don't assume QLocale::codecForLocale always returns non-null It may return null during program exit, due to QCoreGlobalData global static already having been destroyed. If that's the case, QTextStream needs to fall back to Latin 1, like QString::toLocal8Bit and fromLocal8Bit already do. Task-number: QTBUG-38316 Change-Id: I5949c8dec15b60f4a13b5d9307ed6abfc799fe20 Reviewed-by: Olivier Goffart --- tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp index c19e80bff3..2ae085cb0b 100644 --- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp @@ -247,6 +247,13 @@ private: QString testFileName; }; +void runOnExit() +{ + QByteArray buffer; + QTextStream(&buffer) << "This will try to use QTextCodec::codecForLocale" << endl; +} +Q_DESTRUCTOR_FUNCTION(runOnExit) + tst_QTextStream::tst_QTextStream() : tempDir(QDir::tempPath() + "/tst_qtextstream.XXXXXX") { -- cgit v1.2.3