diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-04-02 20:20:10 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2022-05-31 15:43:26 +0200 |
commit | 6f2b75a7132dad7fd000eab3f046e9194f6e4aaf (patch) | |
tree | ab1a8f93e47316cba7af9587c48837060b151723 | |
parent | 31e628bbe4d211a5597adf1f42d0cc313e317893 (diff) |
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 <michael.stahl@allotropia.de>
Tested-by: Jenkins
(cherry picked from commit 37f39a4156069ba5f099045ce93370507d9ba215)
-rw-r--r-- | sw/source/core/layout/tabfrm.cxx | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index f549e7049dcd..d5f825c7e3a1 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -1991,8 +1991,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); @@ -2021,6 +2019,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(); @@ -2031,8 +2035,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 ); @@ -2081,15 +2083,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 ) { @@ -2253,11 +2262,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; + } } } @@ -2271,9 +2287,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: @@ -2514,9 +2527,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 |