diff options
author | Robert Griebl <rgriebl@trolltech.com> | 2009-06-10 11:46:23 (GMT) |
---|---|---|
committer | Robert Griebl <rgriebl@trolltech.com> | 2009-06-10 11:46:23 (GMT) |
commit | 7604f8087f88171ef933d8ae08f501467e647338 (patch) | |
tree | 51d071f462ed48d0b25884d9f62b8ba11c5dff13 /src/gui/embedded/qwindowsystem_qws.cpp | |
parent | 8c265860b41214daade7c8a28237c1e07ea71a3c (diff) | |
download | Qt-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/gui/embedded/qwindowsystem_qws.cpp')
-rw-r--r-- | src/gui/embedded/qwindowsystem_qws.cpp | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/src/gui/embedded/qwindowsystem_qws.cpp b/src/gui/embedded/qwindowsystem_qws.cpp index fdcd193..e3d56ad 100644 --- a/src/gui/embedded/qwindowsystem_qws.cpp +++ b/src/gui/embedded/qwindowsystem_qws.cpp @@ -1304,7 +1304,13 @@ QWSServer::QWSServer(int flags, QObject *parent) : QObject(*new QWSServerPrivate, parent) { Q_D(QWSServer); - d->initServer(flags); + QT_TRY { + d->initServer(flags); + } QT_CATCH(...) { + qwsServer = 0; + qwsServerPrivate = 0; + QT_RETHROW; + } } #ifdef QT3_SUPPORT @@ -1750,21 +1756,23 @@ void QWSServerPrivate::cleanupFonts(bool force) #if defined(QWS_DEBUG_FONTCLEANUP) qDebug() << "cleanupFonts()"; #endif - QMap<QByteArray, int>::Iterator it = fontReferenceCount.begin(); - while (it != fontReferenceCount.end()) { - if (it.value() && !force) { - ++it; - continue; - } + if (!fontReferenceCount.isEmpty()) { + QMap<QByteArray, int>::Iterator it = fontReferenceCount.begin(); + while (it != fontReferenceCount.end()) { + if (it.value() && !force) { + ++it; + continue; + } - const QByteArray &fontName = it.key(); + const QByteArray &fontName = it.key(); #if defined(QWS_DEBUG_FONTCLEANUP) - qDebug() << "removing unused font file" << fontName; + qDebug() << "removing unused font file" << fontName; #endif - QFile::remove(QFile::decodeName(fontName)); - sendFontRemovedEvent(fontName); + QFile::remove(QFile::decodeName(fontName)); + sendFontRemovedEvent(fontName); - it = fontReferenceCount.erase(it); + it = fontReferenceCount.erase(it); + } } if (crashedClientIds.isEmpty()) @@ -3966,7 +3974,8 @@ void QWSServerPrivate::openDisplay() void QWSServerPrivate::closeDisplay() { - qt_screen->shutdownDevice(); + if (qt_screen) + qt_screen->shutdownDevice(); } /*! @@ -4065,9 +4074,14 @@ void QWSServer::startup(int flags) void QWSServer::closedown() { - unlink(qws_qtePipeFilename().toLatin1().constData()); - delete qwsServer; + QScopedPointer<QWSServer> server(qwsServer); qwsServer = 0; + QT_TRY { + unlink(qws_qtePipeFilename().toLatin1().constData()); + } QT_CATCH(const std::bad_alloc &) { + // ### TODO - what to do when we run out of memory + // when calling toLatin1? + } } void QWSServerPrivate::emergency_cleanup() |