summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2012-02-06 13:31:41 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-02-08 00:52:00 (GMT)
commitf41135a9f83d17b319ad050dfacc7a8e88598151 (patch)
tree19c825c7e0aff03157ed07164bf9811653d1fa91 /tests/auto
parent2e220e4603d6a0c21efee3a884be76e9f2d7ebb7 (diff)
downloadQt-f41135a9f83d17b319ad050dfacc7a8e88598151.zip
Qt-f41135a9f83d17b319ad050dfacc7a8e88598151.tar.gz
Qt-f41135a9f83d17b319ad050dfacc7a8e88598151.tar.bz2
Make QString::latin1() re-entrant, the global QHash needs a mutex.
*Different* instances of QString used in different threads would often lead to crashes due to the global QHash used by latin1() and ascii(). Basic autotest for latin1() added. Change-Id: If4fd450deb28f41b1d71f377cacb8815ddeffbee Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qstring/qstring.pro2
-rw-r--r--tests/auto/qstring/tst_qstring.cpp19
2 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/qstring/qstring.pro b/tests/auto/qstring/qstring.pro
index 1c123ad..bfd3a67 100644
--- a/tests/auto/qstring/qstring.pro
+++ b/tests/auto/qstring/qstring.pro
@@ -9,3 +9,5 @@ DEFINES += QT_NO_CAST_TO_ASCII
CONFIG += parallel_test
contains(QT_CONFIG,icu):DEFINES += QT_USE_ICU
+
+contains(QT_CONFIG, qt3support): DEFINES += QT3_SUPPORT
diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp
index 7f207d4..0877b7d 100644
--- a/tests/auto/qstring/tst_qstring.cpp
+++ b/tests/auto/qstring/tst_qstring.cpp
@@ -152,6 +152,7 @@ private slots:
// void indexOf3();
void sprintf();
void copy();
+ void latin1();
void fill();
void truncate();
void constructor();
@@ -917,6 +918,24 @@ void tst_QString::copy()
#endif
}
+void tst_QString::latin1()
+{
+#ifdef QT3_SUPPORT
+ QString e = "String E";
+ const char* lat = e.latin1();
+ QCOMPARE(lat, "String E");
+ e += "F";
+ QCOMPARE(e.latin1(), "String EF");
+
+ QString null;
+ QString empty = "";
+ QCOMPARE(null.latin1(), ""); // was a null pointer in Qt3!
+ QCOMPARE(empty.latin1(), "");
+#else
+ QSKIP("This test requires QT3_SUPPORT", SkipSingle);
+#endif
+}
+
void tst_QString::sprintf()
{
QString a;