summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-05-08 10:50:01 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-05-08 11:04:34 (GMT)
commit4f1f40791ed7e6aec845752680c525efbcb9be84 (patch)
tree9fdfb0d67c42eab6b15030b837c5b44cae225af6 /src/gui/text
parentbf4d57a1477dbe800a53ccda3d8c4fe564b5092c (diff)
downloadQt-4f1f40791ed7e6aec845752680c525efbcb9be84.zip
Qt-4f1f40791ed7e6aec845752680c525efbcb9be84.tar.gz
Qt-4f1f40791ed7e6aec845752680c525efbcb9be84.tar.bz2
Fix reentrency of the QCSS engine.
QTextDocument which is suposed to be reentrant may use the CSS Parser in different threads. The way the indexOfId was computed is not thread safe. Insert the pre-computed value instead Reviewed-by: Thierry
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qcssparser.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index db1e781..8214e54 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -278,19 +278,15 @@ static const QCssKnownValue values[NumKnownValues - 1] = {
{ "xx-large", Value_XXLarge }
};
+//Map id to strings as they appears in the 'values' array above
+static const int indexOfId[NumKnownValues] = { 0, 40, 47, 41, 48, 53, 34, 26, 68, 69, 25, 42, 5, 62, 46,
+ 29, 57, 58, 27, 50, 60, 6, 10, 38, 55, 19, 13, 17, 18, 20, 21, 49, 24, 45, 65, 36, 3, 2, 39, 61, 16,
+ 11, 56, 14, 32, 63, 54, 64, 33, 67, 8, 28, 37, 12, 35, 59, 7, 9, 4, 66, 52, 22, 23, 30, 31, 1, 15, 0,
+ 51, 44, 43 };
+
QString Value::toString() const
{
- static int indexOfId[NumKnownValues - 1];
- static bool hasCachedIndexes = false;
-
if (type == KnownIdentifier) {
- if (!hasCachedIndexes) {
- for (int i = 0; i < NumKnownValues - 1; ++i)
- indexOfId[values[i].id] = i;
-
- hasCachedIndexes = true;
- }
-
return QLatin1String(values[indexOfId[variant.toInt()]].name);
} else {
return variant.toString();