oox/source/core/filterbase.cxx | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)
New commits: commit cbfc87cb39406045e6f561a178bec3c7d10fae02 Author: Vasily Melenchuk <[email protected]> AuthorDate: Sun Oct 13 21:29:24 2019 +0300 Commit: Thorsten Behrens <[email protected]> CommitDate: Sat Nov 16 19:19:40 2019 +0100 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 <[email protected]> diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx index c99c77ba870f..b7acbe084a5c 100644 --- a/oox/source/core/filterbase.cxx +++ b/oox/source/core/filterbase.cxx @@ -30,6 +30,7 @@ #include <cppuhelper/supportsservice.hxx> #include <comphelper/documentconstants.hxx> #include <comphelper/sequence.hxx> +#include <comphelper/scopeguard.hxx> #include <unotools/mediadescriptor.hxx> #include <osl/mutex.hxx> #include <osl/diagnose.h> @@ -159,8 +160,6 @@ struct FilterBaseImpl /// @throws IllegalArgumentException void setDocumentModel( const Reference< XComponent >& rxComponent ); - - void initializeFilter(); }; FilterBaseImpl::FilterBaseImpl( const Reference< XComponentContext >& rxContext ) : @@ -185,18 +184,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 ) ) { @@ -472,7 +459,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: @@ -492,7 +484,6 @@ sal_Bool SAL_CALL FilterBase::filter( const Sequence< PropertyValue >& rMediaDes } break; } - mxImpl->mxModel->unlockControllers(); } return bRet; } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
