diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-12 08:58:11 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-12 08:58:11 (GMT) |
commit | ec171d35582ea440a1a790296e1875876ae7c568 (patch) | |
tree | 5de5665d5f9d2d8dd23e3d54abc960e09e39a124 /src/corelib/codecs/qtextcodec.cpp | |
parent | 053cc8df0e59561e083971a3ac99d4aaf0e86b1d (diff) | |
parent | a321fd32ae1008736246b90ff0b149af498970ac (diff) | |
download | Qt-ec171d35582ea440a1a790296e1875876ae7c568.zip Qt-ec171d35582ea440a1a790296e1875876ae7c568.tar.gz Qt-ec171d35582ea440a1a790296e1875876ae7c568.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt-s60-public into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/qt-s60-public:
econd half of the crash fix for codecs on Symbian
Diffstat (limited to 'src/corelib/codecs/qtextcodec.cpp')
-rw-r--r-- | src/corelib/codecs/qtextcodec.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 1a08cca..18538e3 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -103,6 +103,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QTextCodecFactoryInterface_iid, QLatin1String("/codecs"))) #endif + static char qtolower(register char c) { if (c >= 'A' && c <= 'Z') return c + 0x20; return c; } static bool qisalnum(register char c) @@ -217,6 +218,19 @@ QTextCodecCleanup::~QTextCodecCleanup() Q_GLOBAL_STATIC(QTextCodecCleanup, createQTextCodecCleanup) +bool QTextCodec::validCodecs() +{ +#ifdef Q_OS_SYMBIAN + // If we don't have a trap handler, we're outside of the main() function, + // ie. in global constructors or destructors. Don't use codecs in this + // case as it would lead to crashes because we don't have a cleanup stack on Symbian + return (User::TrapHandler() != NULL); +#else + return true; +#endif +} + + #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) class QWindowsLocalCodec: public QTextCodec { @@ -672,6 +686,9 @@ static void setup() return; #ifdef Q_OS_SYMBIAN + // If we don't have a trap handler, we're outside of the main() function, + // ie. in global constructors or destructors. Don't create codecs in this + // case as it would lead to crashes because of a missing cleanup stack on Symbian if (User::TrapHandler() == NULL) return; #endif @@ -969,6 +986,9 @@ QTextCodec *QTextCodec::codecForName(const QByteArray &name) #endif setup(); + if (!validCodecs()) + return 0; + static QHash <QByteArray, QTextCodec *> cache; if (clearCaches & 0x1) { cache.clear(); @@ -1010,6 +1030,9 @@ QTextCodec* QTextCodec::codecForMib(int mib) #endif setup(); + if (!validCodecs()) + return 0; + static QHash <int, QTextCodec *> cache; if (clearCaches & 0x2) { cache.clear(); @@ -1057,6 +1080,10 @@ QList<QByteArray> QTextCodec::availableCodecs() setup(); QList<QByteArray> codecs; + + if (!validCodecs()) + return codecs; + for (int i = 0; i < all->size(); ++i) { codecs += all->at(i)->name(); codecs += all->at(i)->aliases(); @@ -1095,6 +1122,10 @@ QList<int> QTextCodec::availableMibs() setup(); QList<int> codecs; + + if (!validCodecs()) + return codecs; + for (int i = 0; i < all->size(); ++i) codecs += all->at(i)->mibEnum(); @@ -1145,6 +1176,9 @@ void QTextCodec::setCodecForLocale(QTextCodec *c) QTextCodec* QTextCodec::codecForLocale() { + if (!validCodecs()) + return 0; + if (localeMapper) return localeMapper; |