diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-07-28 20:00:26 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-08-04 18:49:48 +0200 |
commit | ce2792eda318b2760d24d2a744fc89e6a1d87138 (patch) | |
tree | 55ee0998313380481b566c5ff9874f02d5ea5308 /include | |
parent | f9309a171a762b888bdfbea1dba8cbc1683be089 (diff) |
use C++11 exception rethrowing
for those cases where we are doing relatively simple catching and rethrowing
e.g. catch in one thread and throw in main thread.
Change-Id: I6192017c4ec99dd671a9582f7b004096b0fc4525
Reviewed-on: https://gerrit.libreoffice.org/58588
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/vcl/threadex.hxx | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/include/vcl/threadex.hxx b/include/vcl/threadex.hxx index 5eadc125c748..7879536afc9e 100644 --- a/include/vcl/threadex.hxx +++ b/include/vcl/threadex.hxx @@ -61,27 +61,26 @@ public: typedef GenericSolarThreadExecutor<FuncT, ResultT> ExecutorT; ::std::unique_ptr<ExecutorT> const pExecutor( new ExecutorT(func) ); pExecutor->execute(); - if (pExecutor->m_exc.hasValue()) - ::cppu::throwException( pExecutor->m_exc ); + if (pExecutor->m_exc) + std::rethrow_exception(pExecutor->m_exc); return *pExecutor->m_result; } private: explicit GenericSolarThreadExecutor( FuncT const& func ) - : m_exc(), m_func(func), m_result() {} + : m_func(func), m_result() {} virtual void doIt() override { try { m_result.reset( m_func() ); } - catch (css::uno::Exception &) { - // only UNO exceptions can be dispatched: - m_exc = ::cppu::getCaughtException(); + catch (...) { + m_exc = std::current_exception(); } } - css::uno::Any m_exc; + std::exception_ptr m_exc; #ifdef _MSC_VER FuncT m_func; // "const" and std::bind() results in Error C3848 expression would lose const-volatile qualifiers #else @@ -97,20 +96,19 @@ class GenericSolarThreadExecutor<FuncT, void> : public SolarThreadExecutor { private: explicit GenericSolarThreadExecutor( FuncT const& func ) - : m_exc(), m_func(func) {} + : m_func(func) {} virtual void doIt() override { try { m_func(); } - catch (css::uno::Exception &) { - // only UNO exceptions can be dispatched: - m_exc = ::cppu::getCaughtException(); + catch (...) { + m_exc = std::current_exception(); } } - css::uno::Any m_exc; + std::exception_ptr m_exc; FuncT const m_func; }; |