diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-02-16 22:06:42 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-02-16 22:06:42 (GMT) |
commit | ec3dc06b5fbf7ef37e0836992f6d7a3fd49c5891 (patch) | |
tree | 195c66ded290b2ebb4b2398c8967666eb0e7c2aa /src/corelib | |
parent | 95d3bd3fc993d7c8c1fe92960c617a3392d87f66 (diff) | |
parent | 9e5e97f3b5eaa9cda471be44a5c59b51561393b6 (diff) | |
download | Qt-ec3dc06b5fbf7ef37e0836992f6d7a3fd49c5891.zip Qt-ec3dc06b5fbf7ef37e0836992f6d7a3fd49c5891.tar.gz Qt-ec3dc06b5fbf7ef37e0836992f6d7a3fd49c5891.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2: (26 commits)
QLocalSocket::isValid on Windows must check for broken connection
fix pipe handle leak in qlocalsocket_win.cpp
GraphicsViewBenchmark: Run app in full screen mode on small desktops.
Fix Thai text on Windows 7
Fix License headers.
QTextCodec::codecForName. Insert in the cache in all cases.
Prevented calling the pixmap filter implementations with null pixmaps.
Make it possible to run benchmarks with the "-graphicssystem" switch.
Add support for running the GraphicsViewBenchmark application manually.
Bump version to 4.6.3.
Fixed a GLX warning that occured with some Intel chipsets under X11.
Fixed compile for maemo6.
Cleanup QEglContext & EGLDisplays
Moved 'hasAlpha' property from GL2 engine to GL paint device.
Remove useless qDebug in QTextCodec autotest
QTextCodec: Symbian has codec for UCS2, only fallback to UTF16 if UCS2 codec cannot be loaded
Add caching to QTextCodec::codecForName and QTextCodec::codecForMib
Add benchmark for QTextCodec
Fix several bugs with GL texture cache
Compile fix for OpenGL ES.
...
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/codecs/qtextcodec.cpp | 52 | ||||
-rw-r--r-- | src/corelib/global/qglobal.h | 4 |
2 files changed, 45 insertions, 11 deletions
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index ff40af5..c0aa342 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -80,6 +80,7 @@ #endif // QT_NO_CODECS #include "qlocale.h" #include "qmutex.h" +#include "qhash.h" #include <stdlib.h> #include <ctype.h> @@ -172,6 +173,7 @@ static QTextCodec *createForMib(int mib) } static QList<QTextCodec*> *all = 0; +static int clearCaches = 0; // flags specifying if caches should be invalided: 0x1 codecForName, 0x2 codecForMib #ifdef Q_DEBUG_TEXTCODEC static bool destroying_is_ok = false; #endif @@ -935,6 +937,7 @@ QTextCodec::~QTextCodec() QMutexLocker locker(textCodecsMutex()); #endif all->removeAll(this); + clearCaches = 0x1 | 0x2; } } @@ -961,17 +964,33 @@ QTextCodec *QTextCodec::codecForName(const QByteArray &name) #endif setup(); + static QHash <QByteArray, QTextCodec *> cache; + if (clearCaches & 0x1) { + cache.clear(); + clearCaches &= ~0x1; + } + QTextCodec *codec = cache.value(name); + if (codec) + return codec; + for (int i = 0; i < all->size(); ++i) { QTextCodec *cursor = all->at(i); - if (nameMatch(cursor->name(), name)) + if (nameMatch(cursor->name(), name)) { + cache.insert(name, cursor); return cursor; + } QList<QByteArray> aliases = cursor->aliases(); for (int y = 0; y < aliases.size(); ++y) - if (nameMatch(aliases.at(y), name)) + if (nameMatch(aliases.at(y), name)) { + cache.insert(name, cursor); return cursor; + } } - return createForName(name); + codec = createForName(name); + if (codec) + cache.insert(name, codec); + return codec; } @@ -986,19 +1005,34 @@ QTextCodec* QTextCodec::codecForMib(int mib) #endif setup(); - // Qt 3 used 1000 (mib for UCS2) as its identifier for the utf16 codec. Map - // this correctly for compatibility. - if (mib == 1000) - mib = 1015; + static QHash <int, QTextCodec *> cache; + if (clearCaches & 0x2) { + cache.clear(); + clearCaches &= ~0x2; + } + QTextCodec *codec = cache.value(mib); + if (codec) + return codec; QList<QTextCodec*>::ConstIterator i; for (int i = 0; i < all->size(); ++i) { QTextCodec *cursor = all->at(i); - if (cursor->mibEnum() == mib) + if (cursor->mibEnum() == mib) { + cache.insert(mib, cursor); return cursor; + } } - return createForMib(mib); + codec = createForMib(mib); + + // Qt 3 used 1000 (mib for UCS2) as its identifier for the utf16 codec. Map + // this correctly for compatibility. + if (!codec && mib == 1000) + return codecForMib(1015); + + if (codec) + cache.insert(mib, codec); + return codec; } /*! diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index f51849b..9edf929 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -44,11 +44,11 @@ #include <stddef.h> -#define QT_VERSION_STR "4.6.2" +#define QT_VERSION_STR "4.6.3" /* QT_VERSION is (major << 16) + (minor << 8) + patch. */ -#define QT_VERSION 0x040602 +#define QT_VERSION 0x040603 /* can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) */ |