Kaydet (Commit) 70387560 authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

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 81ec6912 ("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: 's avatarJan-Marek Glogowski <glogow@fbihome.de>
(cherry picked from commit d59e44bc)
Reviewed-on: https://gerrit.libreoffice.org/65119
üst 3e3c3619
......@@ -503,57 +503,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];
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment