summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authormread <qt-info@nokia.com>2010-04-06 13:05:01 (GMT)
committermread <qt-info@nokia.com>2010-04-07 08:29:10 (GMT)
commit71df6edab122730c38ac238e168a4cc35b6f4857 (patch)
tree4fa146bf9ce4f6edcb5db256cae10dc7f01aed25 /src/gui/kernel
parent440b48c8601e8a4bb31858c8c5521a0ab8961ef8 (diff)
downloadQt-71df6edab122730c38ac238e168a4cc35b6f4857.zip
Qt-71df6edab122730c38ac238e168a4cc35b6f4857.tar.gz
Qt-71df6edab122730c38ac238e168a4cc35b6f4857.tar.bz2
QTBUG-4887 and other exception safety fixes
This change includes a fix for QTBUG-4887 and other exception safety problems found while testing it. The QTBUG-4887 fix is to qimage.cpp. QImage doesn't throw exceptions on failure like a proper class should, instead it tries to fail "nice". What happens here is that setAlphaChannel would crash on OOM as after the convertToFormat call, d could be NULL. This new version checks the result of the conversion before using it. The other fixes are all cases where exceptions were thrown from destructors. I added code to the test app to help debug these cases, and I fixed all the problems I found. With these changes, tst_exceptionsafety_objects runs and passes on the Symbian emulator. Reviewed-by: Shane Kearns
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qapplication_s60.cpp9
-rw-r--r--src/gui/kernel/qwidget.cpp8
2 files changed, 13 insertions, 4 deletions
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index 37d1b62..e986ce9 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -372,8 +372,13 @@ QSymbianControl::~QSymbianControl()
{
if (S60->curWin == this)
S60->curWin = 0;
- if (!QApplicationPrivate::is_app_closing)
- setFocusSafely(false);
+ if (!QApplicationPrivate::is_app_closing) {
+ QT_TRY {
+ setFocusSafely(false);
+ } QT_CATCH(const std::exception&) {
+ // ignore exceptions, nothing can be done
+ }
+ }
S60->appUi()->RemoveFromStack(this);
delete m_longTapDetector;
}
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index cd943cd..e180001 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -1487,8 +1487,12 @@ QWidget::~QWidget()
if (QWidgetPrivate::allWidgets) // might have been deleted by ~QApplication
QWidgetPrivate::allWidgets->remove(this);
- QEvent e(QEvent::Destroy);
- QCoreApplication::sendEvent(this, &e);
+ QT_TRY {
+ QEvent e(QEvent::Destroy);
+ QCoreApplication::sendEvent(this, &e);
+ } QT_CATCH(const std::exception&) {
+ // if this fails we can't do anything about it but at least we are not allowed to throw.
+ }
}
int QWidgetPrivate::instanceCounter = 0; // Current number of widget instances