diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-08-15 08:05:51 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-09-19 09:25:14 +0200 |
commit | 3840aede596e6fc24f7ed7df9100fb028134aac6 (patch) | |
tree | 74d1d5efa3b2ad5448181fc185faf226aed192e4 /vcl/win/gdi | |
parent | 10b49dfb3996f99dec8dd0d2ffae2aef4022f395 (diff) |
Unify SolarMutex implementations
All backends implement the SolarMutex in mostly the same way.
So this consolidates this code into a GenericSolarMutex.
We still need the abstract SolarMutex class for the fake AKA
fascade implementation in dbaccess.
The patch also replaces various places of direct mutex usage with
either SolarMutexGuard or SolarMutexReleaser objects.
Change-Id: Ia0146dd6c51a3b9a513cc6af34a66def58aad831
Reviewed-on: https://gerrit.libreoffice.org/42325
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/win/gdi')
-rw-r--r-- | vcl/win/gdi/salprn.cxx | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx index 365bf44c06e4..4775e804f2f9 100644 --- a/vcl/win/gdi/salprn.cxx +++ b/vcl/win/gdi/salprn.cxx @@ -396,16 +396,17 @@ static bool ImplUpdateSalJobSetup( WinSalInfoPrinter const * pPrinter, ImplJobSe } // Release mutex, in the other case we don't get paints and so on - sal_uLong nMutexCount=0; - if ( pVisibleDlgParent ) - nMutexCount = ImplSalReleaseYieldMutex(); + sal_uInt32 nMutexCount = 0; + WinSalInstance* pInst = GetSalData()->mpFirstInstance; + if ( pInst && pVisibleDlgParent ) + nMutexCount = pInst->ReleaseYieldMutex( true ); BYTE* pOutDevMode = (reinterpret_cast<BYTE*>(pOutBuffer) + pOutBuffer->mnDriverOffset); nRet = DocumentPropertiesW( hWnd, hPrn, pPrinterNameW, reinterpret_cast<LPDEVMODEW>(pOutDevMode), reinterpret_cast<LPDEVMODEW>(const_cast<BYTE *>(pInBuffer)), nMode ); - if ( pVisibleDlgParent ) - ImplSalAcquireYieldMutex( nMutexCount ); + if ( pInst && pVisibleDlgParent ) + pInst->AcquireYieldMutex( nMutexCount ); ClosePrinter( hPrn ); if( (nRet < 0) || (pVisibleDlgParent && (nRet == IDCANCEL)) ) @@ -1522,6 +1523,14 @@ bool WinSalPrinter::StartJob( const OUString* pFileName, return TRUE; } +void WinSalPrinter::DoEndDoc(HDC hDC) +{ + CATCH_DRIVER_EX_BEGIN; + if( ::EndDoc( hDC ) <= 0 ) + GetLastError(); + CATCH_DRIVER_EX_END( "exception in EndDoc", this ); +} + bool WinSalPrinter::EndJob() { HDC hDC = mhDC; @@ -1540,13 +1549,10 @@ bool WinSalPrinter::EndJob() // it should be safe to release the yield mutex over the EndDoc // call, however the real solution is supposed to be the threading // framework yet to come. - volatile sal_uLong nAcquire = GetSalData()->mpFirstInstance->ReleaseYieldMutex(); - CATCH_DRIVER_EX_BEGIN; - if( ::EndDoc( hDC ) <= 0 ) - GetLastError(); - CATCH_DRIVER_EX_END( "exception in EndDoc", this ); - - GetSalData()->mpFirstInstance->AcquireYieldMutex( nAcquire ); + { + SolarMutexReleaser aReleaser; + DoEndDoc( hDC ); + } DeleteDC( hDC ); mhDC = nullptr; } |