[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - vcl/osx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Dec 14 15:22:18 UTC 2018


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

New commits:
commit 7038756003818f9c98866fa30316950172281043
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: Fri Dec 14 16:21:50 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>
    (cherry picked from commit d59e44bc18bea4bccfa87865200d889f65e10bf1)
    Reviewed-on: https://gerrit.libreoffice.org/65119

diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm
index 8d44135b885d..3fe5b274e388 100644
--- a/vcl/osx/salframeview.mm
+++ b/vcl/osx/salframeview.mm
@@ -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];
     }
 }
 


More information about the Libreoffice-commits mailing list