summaryrefslogtreecommitdiff
path: root/vcl/osx
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2018-12-12 11:06:53 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2018-12-13 18:33:19 +0100
commitd59e44bc18bea4bccfa87865200d889f65e10bf1 (patch)
tree198320a35b865c3dfc2edbf873dba43fd617b7e2 /vcl/osx
parent0a772eeefdbc42f5c17c8c0e39476b95cae237c2 (diff)
tdf#120342 OSX always lock SolarMutex in drawRect
Since we're now a good OSX citizen and do all our drawing in the main thread, I believe the workaround from i#93512 and merged in commit 81ec69125209 ("CWS-TOOLING: integrate CWS i93512_DEV300") isn't needed anymore. Therefore we can just claim the SolarMutex and draw. And I couldn't reproduce the deadlock of i#93512 with this patch applied. But I already was wrong a few times and many drawing semantics have changed for OSX 10.14, so I might be wrong again ;-) Change-Id: Ibbf1c1f394038ee5051bc16d2f3c677f4231b2ba Reviewed-on: https://gerrit.libreoffice.org/65009 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/osx')
-rw-r--r--vcl/osx/salframeview.mm62
1 files changed, 18 insertions, 44 deletions
diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm
index 241cb388409f..3d89e179484d 100644
--- a/vcl/osx/salframeview.mm
+++ b/vcl/osx/salframeview.mm
@@ -506,57 +506,31 @@ static AquaSalFrame* getMouseContainerFrame()
return NO;
}
-// helper class similar to a osl::Guard< comphelper::SolarMutex > for the
-// SalYieldMutex; the difference is that it only does tryToAcquire instead of
-// acquire so dreaded deadlocks like #i93512# are prevented
-class TryGuard
-{
-public:
- TryGuard() { mbGuarded = ImplSalYieldMutexTryToAcquire(); }
- ~TryGuard() { if( mbGuarded ) ImplSalYieldMutexRelease(); }
- bool IsGuarded() { return mbGuarded; }
-private:
- bool mbGuarded;
-};
-
-(void)drawRect: (NSRect)aRect
{
- if( GetSalData()->mpInstance )
- {
- const bool bIsLiveResize = [self inLiveResize];
- const bool bWasLiveResize = GetSalData()->mpInstance->mbIsLiveResize;
- if ( bWasLiveResize != bIsLiveResize )
- {
- GetSalData()->mpInstance->mbIsLiveResize = bIsLiveResize;
- Scheduler::ProcessTaskScheduling();
- }
- }
+ AquaSalInstance *pInstance = GetSalData()->mpInstance;
+ assert(pInstance);
+ if (!pInstance)
+ return;
- // HOTFIX: #i93512# prevent deadlocks if any other thread already has the SalYieldMutex
- TryGuard aTryGuard;
- if( !aTryGuard.IsGuarded() )
- {
- // NOTE: the mpFrame access below is not guarded yet!
- // TODO: mpFrame et al need to be guarded by an independent mutex
- AquaSalGraphics* pGraphics = (mpFrame && AquaSalFrame::isAlive(mpFrame)) ? mpFrame->mpGraphics : nullptr;
- if( pGraphics )
- {
- // we did not get the mutex so we cannot draw now => request to redraw later
- // convert the NSRect to a CGRect for Refreshrect()
- const CGRect aCGRect = {{aRect.origin.x,aRect.origin.y},{aRect.size.width,aRect.size.height}};
- pGraphics->RefreshRect( aCGRect );
- }
+ SolarMutexGuard aGuard;
+ if (!mpFrame || !AquaSalFrame::isAlive(mpFrame))
return;
+
+ const bool bIsLiveResize = [self inLiveResize];
+ const bool bWasLiveResize = pInstance->mbIsLiveResize;
+ if (bWasLiveResize != bIsLiveResize)
+ {
+ pInstance->mbIsLiveResize = bIsLiveResize;
+ Scheduler::ProcessTaskScheduling();
}
- if( mpFrame && AquaSalFrame::isAlive( mpFrame ) )
+ AquaSalGraphics* pGraphics = mpFrame->mpGraphics;
+ if (pGraphics)
{
- if( mpFrame->mpGraphics )
- {
- mpFrame->mpGraphics->UpdateWindow( aRect );
- if( mpFrame->getClipPath() )
- [mpFrame->getNSWindow() invalidateShadow];
- }
+ pGraphics->UpdateWindow(aRect);
+ if (mpFrame->getClipPath())
+ [mpFrame->getNSWindow() invalidateShadow];
}
}