summaryrefslogtreecommitdiffstats
path: root/src/corelib/codecs/qtextcodec.cpp
diff options
context:
space:
mode:
authorRobert Griebl <rgriebl@trolltech.com>2009-06-10 11:46:23 (GMT)
committerRobert Griebl <rgriebl@trolltech.com>2009-06-10 11:46:23 (GMT)
commit7604f8087f88171ef933d8ae08f501467e647338 (patch)
tree51d071f462ed48d0b25884d9f62b8ba11c5dff13 /src/corelib/codecs/qtextcodec.cpp
parent8c265860b41214daade7c8a28237c1e07ea71a3c (diff)
downloadQt-7604f8087f88171ef933d8ae08f501467e647338.zip
Qt-7604f8087f88171ef933d8ae08f501467e647338.tar.gz
Qt-7604f8087f88171ef933d8ae08f501467e647338.tar.bz2
Make Qt exception safer.
Squashed commit of the branch haralds-haralds-qt-s60-topics/topic/exceptions, which also contains the full history. Rev-By: Harald Fernengel Rev-By: Ralf Engels
Diffstat (limited to 'src/corelib/codecs/qtextcodec.cpp')
-rw-r--r--src/corelib/codecs/qtextcodec.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 6e8ffa1..cfb62c7 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -92,6 +92,11 @@
# define QT_NO_SETLOCALE
#endif
+#if 0 // ### TODO - remove me!
+// enabling this is not exception safe!
+#define Q_DEBUG_TEXTCODEC
+#endif
+
QT_BEGIN_NAMESPACE
#ifndef QT_NO_TEXTCODECPLUGIN
@@ -165,7 +170,9 @@ static QTextCodec *createForMib(int mib)
}
static QList<QTextCodec*> *all = 0;
+#ifdef Q_DEBUG_TEXTCODEC
static bool destroying_is_ok = false;
+#endif
static QTextCodec *localeMapper = 0;
QTextCodec *QTextCodec::cftr = 0;
@@ -187,15 +194,21 @@ QTextCodecCleanup::~QTextCodecCleanup()
if (!all)
return;
+#ifdef Q_DEBUG_TEXTCODEC
destroying_is_ok = true;
+#endif
- while (all->size())
- delete all->takeFirst();
+ for (QList<QTextCodec *>::const_iterator it = all->constBegin()
+ ; it != all->constEnd(); ++it) {
+ delete *it;
+ }
delete all;
all = 0;
localeMapper = 0;
+#ifdef Q_DEBUG_TEXTCODEC
destroying_is_ok = false;
+#endif
}
Q_GLOBAL_STATIC(QTextCodecCleanup, createQTextCodecCleanup)
@@ -659,8 +672,10 @@ static void setup()
if (all)
return;
+#ifdef Q_DEBUG_TEXTCODEC
if (destroying_is_ok)
qWarning("QTextCodec: Creating new codec during codec cleanup");
+#endif
all = new QList<QTextCodec*>;
// create the cleanup object to cleanup all codecs on exit
(void) createQTextCodecCleanup();
@@ -915,8 +930,10 @@ QTextCodec::QTextCodec()
*/
QTextCodec::~QTextCodec()
{
+#ifdef Q_DEBUG_TEXTCODEC
if (!destroying_is_ok)
qWarning("QTextCodec::~QTextCodec: Called by application");
+#endif
if (all)
all->removeAll(this);
}