From 80af51be1aa85733b9c0b696a93edd8c6520811c Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Wed, 8 Nov 2017 14:22:44 +0200 Subject: ODBFilter::filter: Also leave window wait on exception Change-Id: I6bb759c583e15f229bc2afa178a1d1d90d8315ef Reviewed-on: https://gerrit.libreoffice.org/44458 Reviewed-by: Noel Grandin Tested-by: Jenkins Reviewed-by: Mike Kaganski --- dbaccess/source/filter/xml/xmlfilter.cxx | 38 +++++++++++++++++++------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/dbaccess/source/filter/xml/xmlfilter.cxx b/dbaccess/source/filter/xml/xmlfilter.cxx index 8069a577f8e1..f386206bec66 100644 --- a/dbaccess/source/filter/xml/xmlfilter.cxx +++ b/dbaccess/source/filter/xml/xmlfilter.cxx @@ -244,30 +244,38 @@ css::uno::Reference< css::uno::XInterface > return static_cast< XServiceInfo* >(new ODBFilter( comphelper::getComponentContext(_rxORB))); } - -sal_Bool SAL_CALL ODBFilter::filter( const Sequence< PropertyValue >& rDescriptor ) +namespace { +class FocusWindowWaitGuard { - uno::Reference< css::awt::XWindow > xWindow; +public: + FocusWindowWaitGuard() { SolarMutexGuard aGuard; - vcl::Window* pFocusWindow = Application::GetFocusWindow(); - xWindow = VCLUnoHelper::GetInterface( pFocusWindow ); - if( pFocusWindow ) - pFocusWindow->EnterWait(); + mpWindow.set(Application::GetFocusWindow()); + if (mpWindow) + mpWindow->EnterWait(); } + ~FocusWindowWaitGuard() + { + if (mpWindow) + { + SolarMutexGuard aGuard; + mpWindow->LeaveWait(); + } + } +private: + VclPtr mpWindow; +}; +} + +sal_Bool SAL_CALL ODBFilter::filter( const Sequence< PropertyValue >& rDescriptor ) +{ + FocusWindowWaitGuard aWindowFocusGuard; bool bRet = false; if ( GetModel().is() ) bRet = implImport( rDescriptor ); - if ( xWindow.is() ) - { - SolarMutexGuard aGuard; - VclPtr pFocusWindow = VCLUnoHelper::GetWindow( xWindow ); - if ( pFocusWindow ) - pFocusWindow->LeaveWait(); - } - return bRet; } -- cgit