[Libreoffice-commits] core.git: editeng/source include/editeng
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Mon Feb 15 12:19:09 UTC 2021
editeng/source/rtf/svxrtf.cxx | 48 +++++++++++-------------------------------
include/editeng/svxrtf.hxx | 4 +--
2 files changed, 15 insertions(+), 37 deletions(-)
New commits:
commit 08b82fa3ee915666ef8b60aeb670c38f64553630
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Feb 15 10:48:53 2021 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Feb 15 13:18:26 2021 +0100
Revert "ofz#29461 flatten SetAttrSet recursion"
Compress deletes nodes so the flat list becomes invalid
This reverts commit d1b3571fba171279d70ccaa0dfec1871f04439af.
Change-Id: I70e52ac3988493a283ca83121bd2e4a67db6f5ed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110901
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
index 7c1d885323e3..17ef94553ec5 100644
--- a/editeng/source/rtf/svxrtf.cxx
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -848,42 +848,14 @@ void SvxRTFParser::SetAllAttrOfStk() // end all Attr. and set it into doc
for (size_t n = m_AttrSetList.size(); n; )
{
auto const& pStkSet = m_AttrSetList[--n];
-
- /*
- ofz#29461 SetAttrSet recursively calls SetAttrSet on pStkSet's
- m_pChildList. The recurse depth can grow sufficiently to trigger
- asan.
-
- So breadth-first iterate through the nodes and make a flat vector of
- them which can be iterated through linearly
- */
- auto bfs = pStkSet->GetBreadthFirstList();
- for (auto it = bfs.begin(); it != bfs.end(); ++it)
- {
- SvxRTFItemStackType* pNode = *it;
- SetAttrSet(*pNode, false);
- }
-
- /*
- ofz#13491 SvxRTFItemStackType dtor recursively calls the dtor of its
- m_pChildList. The recurse depth can grow sufficiently to trigger
- asan.
-
- iterate through flat-view of those nodes in order of most distant
- from root first and release them linearly
- */
- for (auto it = bfs.rbegin(); it != bfs.rend(); ++it)
- {
- SvxRTFItemStackType* pNode = *it;
- pNode->m_pChildList.reset();
- }
-
+ SetAttrSet( *pStkSet );
+ pStkSet->DropChildList();
m_AttrSetList.pop_back();
}
}
// sets all the attributes that are different from the current
-void SvxRTFParser::SetAttrSet(SvxRTFItemStackType &rSet, bool bRecurse)
+void SvxRTFParser::SetAttrSet( SvxRTFItemStackType &rSet )
{
// Was DefTab never read? then set to default
if( !bIsSetDfltTab )
@@ -895,7 +867,7 @@ void SvxRTFParser::SetAttrSet(SvxRTFItemStackType &rSet, bool bRecurse)
SetAttrInDoc( rSet );
// then process all the children
- if (bRecurse && rSet.m_pChildList)
+ if (rSet.m_pChildList)
for (size_t n = 0; n < rSet.m_pChildList->size(); ++n)
SetAttrSet( *(*rSet.m_pChildList)[ n ] );
}
@@ -991,10 +963,12 @@ SvxRTFItemStackType::SvxRTFItemStackType(
distant from root first and release
their children linearly
*/
-std::vector<SvxRTFItemStackType*> SvxRTFItemStackType::GetBreadthFirstList()
+void SvxRTFItemStackType::DropChildList()
{
- std::vector<SvxRTFItemStackType*> bfs;
+ if (!m_pChildList || m_pChildList->empty())
+ return;
+ std::vector<SvxRTFItemStackType*> bfs;
std::queue<SvxRTFItemStackType*> aQueue;
aQueue.push(this);
@@ -1010,7 +984,11 @@ std::vector<SvxRTFItemStackType*> SvxRTFItemStackType::GetBreadthFirstList()
}
}
- return bfs;
+ for (auto it = bfs.rbegin(); it != bfs.rend(); ++it)
+ {
+ SvxRTFItemStackType* pNode = *it;
+ pNode->m_pChildList.reset();
+ }
}
SvxRTFItemStackType::~SvxRTFItemStackType()
diff --git a/include/editeng/svxrtf.hxx b/include/editeng/svxrtf.hxx
index 70e996068459..faff107c1496 100644
--- a/include/editeng/svxrtf.hxx
+++ b/include/editeng/svxrtf.hxx
@@ -197,7 +197,7 @@ class EDITENG_DLLPUBLIC SvxRTFParser : public SvRTFParser
void ClearStyleAttr_( SvxRTFItemStackType& rStkType );
// Sets all the attributes that are different from the current
- void SetAttrSet(SvxRTFItemStackType &rSet, bool bRecurse = true);
+ void SetAttrSet( SvxRTFItemStackType &rSet );
void SetDefault( int nToken, int nValue );
// Execute pard / plain
@@ -309,7 +309,7 @@ class SvxRTFItemStackType
void Add(std::unique_ptr<SvxRTFItemStackType>);
void Compress( const SvxRTFParser& );
- std::vector<SvxRTFItemStackType*> GetBreadthFirstList();
+ void DropChildList();
public:
SvxRTFItemStackType(const SvxRTFItemStackType&, const EditPosition&,
More information about the Libreoffice-commits
mailing list