From 37f39a4156069ba5f099045ce93370507d9ba215 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sat, 2 Apr 2022 20:20:10 +0100 Subject: 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 Tested-by: Jenkins --- sw/source/core/layout/tabfrm.cxx | 42 +++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index adc0491b88ba..e836bfb73a01 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -2023,8 +2023,6 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext) pAccess.reset(); m_bCalcLowers |= pLayout->Resize( pLayout->GetBrowseWidthByTabFrame( *this ) ); - pAccess = std::make_unique(SwFrame::GetCache(), this); - pAttrs = pAccess->Get(); } setFramePrintAreaValid(false); @@ -2059,6 +2057,12 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext) const tools::Long nOldPrtWidth = aRectFnSet.GetWidth(getFramePrintArea()); const tools::Long nOldFrameWidth = aRectFnSet.GetWidth(getFrameArea()); const Point aOldPrtPos = aRectFnSet.GetPos(getFramePrintArea()); + + if (!pAccess) + { + pAccess = std::make_unique(SwFrame::GetCache(), this); + pAttrs = pAccess->Get(); + } Format( getRootFrame()->GetCurrShell()->GetOut(), pAttrs ); SwHTMLTableLayout *pLayout = GetTable()->GetHTMLTableLayout(); @@ -2069,8 +2073,6 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext) pAccess.reset(); m_bCalcLowers |= pLayout->Resize( pLayout->GetBrowseWidthByTabFrame( *this ) ); - pAccess = std::make_unique(SwFrame::GetCache(), this); - pAttrs = pAccess->Get(); } if ( aOldPrtPos != aRectFnSet.GetPos(getFramePrintArea()) ) aNotify.SetLowersComplete( false ); @@ -2119,15 +2121,22 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext) pAccess.reset(); m_bCalcLowers |= pHTMLLayout->Resize( pHTMLLayout->GetBrowseWidthByTabFrame( *this ) ); + } + + setFramePrintAreaValid(false); + if (!pAccess) + { pAccess = std::make_unique(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 ) { @@ -2291,11 +2300,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(GetLastLower()); - if (pLastRow - && IsKeep(pAttrs->GetAttrSet().GetKeep(), GetBreakItem(), true) - && pLastRow->ShouldRowKeepWithNext()) + if (pLastRow) { - bFormat = true; + if (!pAccess) + { + pAccess = std::make_unique(SwFrame::GetCache(), this); + pAttrs = pAccess->Get(); + } + if (IsKeep(pAttrs->GetAttrSet().GetKeep(), GetBreakItem(), true) + && pLastRow->ShouldRowKeepWithNext()) + { + bFormat = true; + } } } @@ -2309,9 +2325,6 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext) // is found, get its first content. const SwFrame* pTmpNxt = sw_FormatNextContentForKeep( this ); - pAccess = std::make_unique(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: @@ -2557,9 +2570,6 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext) GetFollow()->MakeAll(pRenderContext); - pAccess = std::make_unique(SwFrame::GetCache(), this); - pAttrs = pAccess->Get(); - GetFollow()->SetLowersFormatted(false); // #i43913# - lock follow table // to avoid its formatting during the format of -- cgit