diff options
author | Morten Johan Sørvig <morten.sorvig@nokia.com> | 2010-11-11 08:59:53 (GMT) |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@nokia.com> | 2010-11-11 09:06:39 (GMT) |
commit | 98d51e42c81c0674bc724eccbdf8521d9317998a (patch) | |
tree | 75605437441102ca180cfc2771d682b2ab6cab9f /tests/auto/qtconcurrentrun | |
parent | e8ddca677db9b0d3ac8ff1b2079c3b000d59d6ec (diff) | |
download | Qt-98d51e42c81c0674bc724eccbdf8521d9317998a.zip Qt-98d51e42c81c0674bc724eccbdf8521d9317998a.tar.gz Qt-98d51e42c81c0674bc724eccbdf8521d9317998a.tar.bz2 |
Support exception handling in QtConcurrent::run()
Use QFutureInterface::reportException() in the
same way that we do in QtConcurrent::map().
Diffstat (limited to 'tests/auto/qtconcurrentrun')
-rw-r--r-- | tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp index 8fdc50c..8b10ea4 100644 --- a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ b/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp @@ -61,6 +61,9 @@ private slots: void implicitConvertibleTypes(); void runWaitLoop(); void recursive(); +#ifndef QT_NO_EXCEPTIONS + void exceptions(); +#endif #if 0 void createFunctor(); #endif @@ -374,6 +377,41 @@ int fn2(double, int *) return 1; } + +#ifndef QT_NO_EXCEPTIONS +void throwFunction() +{ + throw QtConcurrent::Exception(); +} + +int throwFunctionReturn() +{ + throw QtConcurrent::Exception(); + return 0; +} + +void tst_QtConcurrentRun::exceptions() +{ + bool caught = false; + try { + QtConcurrent::run(throwFunction).waitForFinished(); + } catch (Exception &e) { + caught = true; + } + if (!caught) + QFAIL("did not get exception"); + + caught = false; + try { + QtConcurrent::run(throwFunctionReturn).waitForFinished(); + } catch (Exception &e) { + caught = true; + } + if (!caught) + QFAIL("did not get exception"); +} +#endif + #if 0 void tst_QtConcurrentRun::createFunctor() { |