diff options
author | Murray Read <ext-murray.2.read@nokia.com> | 2012-02-21 16:13:10 +0000 |
---|---|---|
committer | Pasi Pentikäinen <ext-pasi.a.pentikainen@nokia.com> | 2012-02-23 10:42:49 +0100 |
commit | 0710c962498ae46cb5042c8c7cc4776f4e31a5f6 (patch) | |
tree | 0fd66dc970a78dc7e86e404f039b528f0d5b3f0b | |
parent | 12b13dfa0c376bf5740710c7150ebeae004f2942 (diff) | |
download | qt4-tools-0710c962498ae46cb5042c8c7cc4776f4e31a5f6.tar.gz |
Allowing symbian cleanup code in thread started and finished slots
The run() function of QThread was inside a TRAP, but the started() and
finished() signals were emitted outside of a TRAP so could not contain
Symbian cleanup stack code. This broke compatability with some apps,
as the older pthread based implementation had the whole main thread
function running inside a TRAP.
The started and finished signals are now emitted inside TRAPs, with
enhanced leave/exception handling code.
Task-number: ou1cimx1#979704
Change-Id: I9b4e50b1085494b5fd5e05efa11739ce19ff26fb
Reviewed-by: Shane Kearns <ext-shane.2.kearns@nokia.com>
(cherry picked from commit e7320d22ec04c6d14a38b2bc4172d7c0823f88b5)
Reviewed-by: Murray Read <ext-murray.2.read@nokia.com>
Reviewed-by: Pasi Pentikäinen <ext-pasi.a.pentikainen@nokia.com>
-rw-r--r-- | src/corelib/thread/qthread_symbian.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/corelib/thread/qthread_symbian.cpp b/src/corelib/thread/qthread_symbian.cpp index 78bb293c75..9f5bbef09c 100644 --- a/src/corelib/thread/qthread_symbian.cpp +++ b/src/corelib/thread/qthread_symbian.cpp @@ -337,18 +337,26 @@ void *QThreadPrivate::start(void *arg) // ### TODO: allow the user to create a custom event dispatcher createEventDispatcher(data); - emit thr->started(); TRAPD(err, { try { + emit thr->started(); thr->run(); } catch (const std::exception& ex) { qWarning("QThreadPrivate::start: Thread exited on exception %s", ex.what()); + User::Leave(KErrGeneral); // leave to force cleanup stack cleanup } }); if (err) qWarning("QThreadPrivate::start: Thread exited on leave %d", err); - QThreadPrivate::finish(arg); + // finish emits signals which should be wrapped in a trap for Symbian code, but otherwise ignore leaves and exceptions. + TRAP(err, { + try { + QThreadPrivate::finish(arg); + } catch (const std::exception& ex) { + User::Leave(KErrGeneral); // leave to force cleanup stack cleanup + } + }); delete cleanup; |