summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMurray Read <ext-murray.2.read@nokia.com>2012-02-21 16:13:10 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-02-22 14:31:16 (GMT)
commite7320d22ec04c6d14a38b2bc4172d7c0823f88b5 (patch)
tree413c01aea63b1667508160be4a959629d5e1f13e
parent33bb996c83e541c26df632b3e8883a1190cc97f0 (diff)
downloadQt-e7320d22ec04c6d14a38b2bc4172d7c0823f88b5.zip
Qt-e7320d22ec04c6d14a38b2bc4172d7c0823f88b5.tar.gz
Qt-e7320d22ec04c6d14a38b2bc4172d7c0823f88b5.tar.bz2
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>
-rw-r--r--src/corelib/thread/qthread_symbian.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/corelib/thread/qthread_symbian.cpp b/src/corelib/thread/qthread_symbian.cpp
index fc0e450..fd551ff 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;