summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2019-10-13 21:29:24 +0300
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-12-04 13:42:22 +0100
commitf2281a274355e1dc9f85235800ee1855eadac78b (patch)
treef59f699d0ceaa3ecc6eb2c295468ffde9c65899d
parent3a734de43ad32ae9d081dcea1568d743051c01f2 (diff)
oox: avoid control freeze on exception
If exception happens somewhere in exportDocument() or later, document controls could be remain locked and later cause crash due to missing exception handler. Use scope guard to avoid this problem on exception. (cherry picked from commit ce684e7d06fc37ac6b672f5676e6113fcf41a03e) Change-Id: I1ce4e487833ddc4b1f1b708f3a7e10bb299ef354 Reviewed-on: https://gerrit.libreoffice.org/80752 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Conflicts: oox/source/core/filterbase.cxx
-rw-r--r--oox/source/core/filterbase.cxx23
1 files changed, 7 insertions, 16 deletions
diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx
index ede7b7ac06c3..04c33b9f9f2f 100644
--- a/oox/source/core/filterbase.cxx
+++ b/oox/source/core/filterbase.cxx
@@ -29,6 +29,7 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/documentconstants.hxx>
+#include <comphelper/scopeguard.hxx>
#include <unotools/mediadescriptor.hxx>
#include <osl/mutex.hxx>
#include <osl/diagnose.h>
@@ -158,8 +159,6 @@ struct FilterBaseImpl
/// @throws IllegalArgumentException
void setDocumentModel( const Reference< XComponent >& rxComponent );
-
- void initializeFilter();
};
FilterBaseImpl::FilterBaseImpl( const Reference< XComponentContext >& rxContext ) :
@@ -184,18 +183,6 @@ void FilterBaseImpl::setDocumentModel( const Reference< XComponent >& rxComponen
}
}
-void FilterBaseImpl::initializeFilter()
-{
- try
- {
- // lock the model controllers
- mxModel->lockControllers();
- }
- catch( Exception& )
- {
- }
-}
-
FilterBase::FilterBase( const Reference< XComponentContext >& rxContext ) :
mxImpl( new FilterBaseImpl( rxContext ) )
{
@@ -480,7 +467,12 @@ sal_Bool SAL_CALL FilterBase::filter( const Sequence< PropertyValue >& rMediaDes
DocumentOpenedGuard aOpenedGuard( mxImpl->maFileUrl );
if( aOpenedGuard.isValid() || mxImpl->maFileUrl.isEmpty() )
{
- mxImpl->initializeFilter();
+ Reference<XModel> xTempModel = mxImpl->mxModel;
+ xTempModel->lockControllers();
+ comphelper::ScopeGuard const lockControllersGuard([xTempModel]() {
+ xTempModel->unlockControllers();
+ });
+
switch( mxImpl->meDirection )
{
case FILTERDIRECTION_UNKNOWN:
@@ -500,7 +492,6 @@ sal_Bool SAL_CALL FilterBase::filter( const Sequence< PropertyValue >& rMediaDes
}
break;
}
- mxImpl->mxModel->unlockControllers();
}
return bRet;
}