summaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-07-28 20:00:26 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-08-04 18:49:48 +0200
commitce2792eda318b2760d24d2a744fc89e6a1d87138 (patch)
tree55ee0998313380481b566c5ff9874f02d5ea5308 /package
parentfix arm build (diff)
downloadcore-ce2792eda318b2760d24d2a744fc89e6a1d87138.tar.gz
core-ce2792eda318b2760d24d2a744fc89e6a1d87138.zip
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 'package')
-rw-r--r--package/inc/ZipOutputEntry.hxx6
-rw-r--r--package/inc/ZipOutputStream.hxx2
-rw-r--r--package/source/zipapi/XBufferedThreadedStream.cxx3
-rw-r--r--package/source/zipapi/XBufferedThreadedStream.hxx2
-rw-r--r--package/source/zipapi/ZipOutputStream.cxx10
-rw-r--r--package/source/zippackage/ZipPackageStream.cxx4
6 files changed, 13 insertions, 14 deletions
diff --git a/package/inc/ZipOutputEntry.hxx b/package/inc/ZipOutputEntry.hxx
index 2e6c11dfa129..d95ffd4969ab 100644
--- a/package/inc/ZipOutputEntry.hxx
+++ b/package/inc/ZipOutputEntry.hxx
@@ -47,7 +47,7 @@ class ZipOutputEntry
css::uno::Reference< css::xml::crypto::XCipherContext > m_xCipherContext;
css::uno::Reference< css::xml::crypto::XDigestContext > m_xDigestContext;
- ::css::uno::Any m_aParallelDeflateException;
+ std::exception_ptr m_aParallelDeflateException;
CRC32 m_aCRC;
ZipEntry *m_pCurrentEntry;
@@ -70,9 +70,9 @@ public:
const css::uno::Reference< css::uno::XComponentContext >& rxContext,
ZipEntry& rEntry, ZipPackageStream* pStream, bool bEncrypt);
void createBufferFile();
- void setParallelDeflateException(const ::css::uno::Any &rAny) { m_aParallelDeflateException = rAny; }
+ void setParallelDeflateException(const std::exception_ptr& exception) { m_aParallelDeflateException = exception; }
css::uno::Reference< css::io::XInputStream > getData() const;
- const css::uno::Any& getParallelDeflateException() const { return m_aParallelDeflateException; }
+ const std::exception_ptr& getParallelDeflateException() const { return m_aParallelDeflateException; }
void closeBufferFile();
void deleteBufferFile();
diff --git a/package/inc/ZipOutputStream.hxx b/package/inc/ZipOutputStream.hxx
index 2c3e26fab4ac..3f86f07883ca 100644
--- a/package/inc/ZipOutputStream.hxx
+++ b/package/inc/ZipOutputStream.hxx
@@ -40,7 +40,7 @@ class ZipOutputStream
ByteChucker m_aChucker;
ZipEntry *m_pCurrentEntry;
std::vector< ZipOutputEntry* > m_aEntries;
- ::css::uno::Any m_aDeflateException;
+ std::exception_ptr m_aDeflateException;
public:
ZipOutputStream(
diff --git a/package/source/zipapi/XBufferedThreadedStream.cxx b/package/source/zipapi/XBufferedThreadedStream.cxx
index 71683cfaf590..e40613d4b66e 100644
--- a/package/source/zipapi/XBufferedThreadedStream.cxx
+++ b/package/source/zipapi/XBufferedThreadedStream.cxx
@@ -29,9 +29,8 @@ private:
{
mxStream.produce();
}
- catch (const css::uno::Exception &e)
+ catch (...)
{
- SAL_WARN("package", "Unexpected " << e );
mxStream.saveException(std::current_exception());
}
diff --git a/package/source/zipapi/XBufferedThreadedStream.hxx b/package/source/zipapi/XBufferedThreadedStream.hxx
index 5feb6e4252e0..272414c37504 100644
--- a/package/source/zipapi/XBufferedThreadedStream.hxx
+++ b/package/source/zipapi/XBufferedThreadedStream.hxx
@@ -66,7 +66,7 @@ public:
void produce();
void setTerminateThread();
- void saveException(std::exception_ptr exception) { maSavedException = exception; }
+ void saveException(const std::exception_ptr& exception) { maSavedException = exception; }
// XInputStream
virtual sal_Int32 SAL_CALL readBytes( css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) override;
diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx
index c15fdaee48ef..c98876fdc6c1 100644
--- a/package/source/zipapi/ZipOutputStream.cxx
+++ b/package/source/zipapi/ZipOutputStream.cxx
@@ -94,10 +94,10 @@ void ZipOutputStream::rawCloseEntry( bool bEncrypt )
void ZipOutputStream::consumeScheduledThreadEntry(ZipOutputEntry* pCandidate)
{
//Any exceptions thrown in the threads were caught and stored for now
- ::css::uno::Any aCaughtException(pCandidate->getParallelDeflateException());
- if (aCaughtException.hasValue())
+ const std::exception_ptr& rCaughtException(pCandidate->getParallelDeflateException());
+ if (rCaughtException)
{
- m_aDeflateException = aCaughtException; // store it for later throwing
+ m_aDeflateException = rCaughtException; // store it for later throwing
// the exception handler in DeflateThread should have cleaned temp file
delete pCandidate;
return;
@@ -184,9 +184,9 @@ void ZipOutputStream::finish()
m_xStream->flush();
m_aZipList.clear();
- if (m_aDeflateException.hasValue())
+ if (m_aDeflateException)
{ // throw once all threads are finished and m_aEntries can be released
- ::cppu::throwException(m_aDeflateException);
+ std::rethrow_exception(m_aDeflateException);
}
}
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index 0c780718b251..5fe4d0ef80c5 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -473,9 +473,9 @@ private:
mpEntry->closeBufferFile();
mpEntry->setFinished();
}
- catch (const uno::Exception&)
+ catch (...)
{
- mpEntry->setParallelDeflateException(::cppu::getCaughtException());
+ mpEntry->setParallelDeflateException(std::current_exception());
try
{
if (mpEntry->m_xOutStream.is())