sw/source/core/layout/tabfrm.cxx |   42 ++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 16 deletions(-)

New commits:
commit 7c843c2b2099ec325dd95413892a2c72bb98dd8e
Author:     Caolán McNamara <[email protected]>
AuthorDate: Sat Apr 2 20:20:10 2022 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Mon May 16 12:32:16 2022 +0200

    forcepoint#100 drop SwBorderAttrAccess to allow cache entry to be removed
    
    for SwBorderAttr which gets deleted during this call
    
    also includes...
    
    Related: forcepoint#100 we don't need pAttrs for the duration of the full 
scope
    
    similar to the case of
    
    commit 6b1eae0334ba8bad7656a859695551ce51b62f95
    Date:   Fri May 18 08:26:14 2001 +0000
    
        Fix #87058#: Locked boraderattribut
    
    the SwCache object cannot be deleted if its locked, leading to a leak,
    we don't need pAttrs for the entire scope here so we can defer to the
    end of the scope the reacquire the lock to set pAttrs
    
    and also includes...
    
    Related: forcepoint#100 don't reacquire after every release
    
    instead release when we have to, and only reacquire if necessary
    before use of pAttrs
    
    Change-Id: Ie52aab7e5933d76b0c055389798104e4d93f39e9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132462
    Reviewed-by: Michael Stahl <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit 37f39a4156069ba5f099045ce93370507d9ba215)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133901
    Tested-by: Michael Stahl <[email protected]>

diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 350083909511..7e48a88f465c 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -1990,8 +1990,6 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
                     pAccess.reset();
                     m_bCalcLowers |= pLayout->Resize(
                         pLayout->GetBrowseWidthByTabFrame( *this ) );
-                    pAccess = 
std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), this);
-                    pAttrs = pAccess->Get();
                 }
 
                 setFramePrintAreaValid(false);
@@ -2020,6 +2018,12 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
             const long nOldPrtWidth = aRectFnSet.GetWidth(getFramePrintArea());
             const long nOldFrameWidth = aRectFnSet.GetWidth(getFrameArea());
             const Point aOldPrtPos  = aRectFnSet.GetPos(getFramePrintArea());
+
+            if (!pAccess)
+            {
+                pAccess = 
std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), this);
+                pAttrs = pAccess->Get();
+            }
             Format( getRootFrame()->GetCurrShell()->GetOut(), pAttrs );
 
             SwHTMLTableLayout *pLayout = GetTable()->GetHTMLTableLayout();
@@ -2030,8 +2034,6 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
                 pAccess.reset();
                 m_bCalcLowers |= pLayout->Resize(
                     pLayout->GetBrowseWidthByTabFrame( *this ) );
-                pAccess = 
std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), this);
-                pAttrs = pAccess->Get();
             }
             if ( aOldPrtPos != aRectFnSet.GetPos(getFramePrintArea()) )
                 aNotify.SetLowersComplete( false );
@@ -2080,15 +2082,22 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
                             pAccess.reset();
                             m_bCalcLowers |= pHTMLLayout->Resize(
                                 pHTMLLayout->GetBrowseWidthByTabFrame( *this ) 
);
+                        }
+
+                        setFramePrintAreaValid(false);
 
+                        if (!pAccess)
+                        {
                             pAccess = 
std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), this);
                             pAttrs = pAccess->Get();
                         }
-
-                        setFramePrintAreaValid(false);
                         Format( getRootFrame()->GetCurrShell()->GetOut(), 
pAttrs );
                     }
+
+                    pAccess.reset();
+
                     lcl_RecalcTable( *this, nullptr, aNotify );
+
                     m_bLowersFormatted = true;
                     if ( bKeep && KEEPTAB )
                     {
@@ -2252,11 +2261,18 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
                     // 6. There is no section change behind the table (see 
IsKeep)
                     // 7. The last table row wants to keep with its next.
                     const SwRowFrame* pLastRow = static_cast<const 
SwRowFrame*>(GetLastLower());
-                    if (pLastRow
-                        && IsKeep(pAttrs->GetAttrSet().GetKeep(), 
GetBreakItem(), true)
-                        && pLastRow->ShouldRowKeepWithNext())
+                    if (pLastRow)
                     {
-                        bFormat = true;
+                        if (!pAccess)
+                        {
+                            pAccess = 
std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), this);
+                            pAttrs = pAccess->Get();
+                        }
+                        if (IsKeep(pAttrs->GetAttrSet().GetKeep(), 
GetBreakItem(), true)
+                            && pLastRow->ShouldRowKeepWithNext())
+                        {
+                            bFormat = true;
+                        }
                     }
                 }
 
@@ -2270,9 +2286,6 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
                     // is found, get its first content.
                     const SwFrame* pTmpNxt = sw_FormatNextContentForKeep( this 
);
 
-                    pAccess = 
std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), this);
-                    pAttrs = pAccess->Get();
-
                     // The last row wants to keep with the frame behind the 
table.
                     // Check if the next frame is on a different page and 
valid.
                     // In this case we do a magic trick:
@@ -2513,9 +2526,6 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
 
                             GetFollow()->MakeAll(pRenderContext);
 
-                            pAccess = 
std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), this);
-                            pAttrs = pAccess->Get();
-
                             GetFollow()->SetLowersFormatted(false);
                             // #i43913# - lock follow table
                             // to avoid its formatting during the format of

Reply via email to