[Libreoffice-commits] core.git: vcl/osx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Dec 13 17:33:47 UTC 2018


 vcl/osx/salframeview.mm |   62 +++++++++++++-----------------------------------
 1 file changed, 18 insertions(+), 44 deletions(-)

New commits:
commit d59e44bc18bea4bccfa87865200d889f65e10bf1
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Wed Dec 12 11:06:53 2018 +0100
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Thu Dec 13 18:33:19 2018 +0100

    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 at fbihome.de>

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];
     }
 }
 


More information about the Libreoffice-commits mailing list