diff options
author | mread <qt-info@nokia.com> | 2010-04-06 13:05:01 (GMT) |
---|---|---|
committer | mread <qt-info@nokia.com> | 2010-04-07 08:29:10 (GMT) |
commit | 71df6edab122730c38ac238e168a4cc35b6f4857 (patch) | |
tree | 4fa146bf9ce4f6edcb5db256cae10dc7f01aed25 /tests | |
parent | 440b48c8601e8a4bb31858c8c5521a0ab8961ef8 (diff) | |
download | Qt-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 'tests')
-rw-r--r-- | tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp index 4433c7a..91d1a44 100644 --- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp +++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp @@ -43,6 +43,7 @@ #include <QtTest/QtTest> #include <stddef.h> +#include <exception> QT_USE_NAMESPACE @@ -285,8 +286,26 @@ void tst_ExceptionSafetyObjects::safeMessageHandler(QtMsgType type, const char * allocFailer.reactivateAt(currentIndex); } +typedef void (*PVF)(); +PVF defaultTerminate; +void debugTerminate() +{ + // you can detect uncaught exceptions with a breakpoint in here + (*defaultTerminate)(); +} + +PVF defaultUnexpected; +void debugUnexpected() +{ + // you can detect unexpected exceptions with a breakpoint in here + (*defaultUnexpected)(); +} + void tst_ExceptionSafetyObjects::initTestCase() { + // set handlers for bad exception cases, you might want to step in and breakpoint the default handlers too + defaultTerminate = std::set_terminate(&debugTerminate); + defaultUnexpected = std::set_unexpected(&debugUnexpected); testMessageHandler = qInstallMsgHandler(safeMessageHandler); QVERIFY(AllocFailer::initialize()); |