diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-05-18 13:52:04 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-06-01 17:33:32 +0200 |
commit | 58d57d666a7ea2044599d9ec47a29ff3c6b588a2 (patch) | |
tree | d03377758c43afab900b5f47e37f99db633201f1 | |
parent | ofz#1220 sanitize nTyp to legal values (diff) | |
download | core-58d57d666a7ea2044599d9ec47a29ff3c6b588a2.tar.gz core-58d57d666a7ea2044599d9ec47a29ff3c6b588a2.zip |
ofz: InsertWithValidRanges didn't report that it deleted its argument anymore
since...
commit ddd84d08c9bb6e00fbd9a73bd52a28688a8c1ba7
Date: Fri Jul 20 17:16:03 2012 +0200
Convert SV_DECL_PTRARR_SORT_DEL(_SwRedlineTbl) to o3tl::sorted_vector
Change-Id: Ie7edc6b32b373619d4c0ac154da93650743049cf
otherwise that p = nullptr line at the end doesn't make sense
Change-Id: Ibd5230beb87240cba4b3896dfa2217e25a4db697
Reviewed-on: https://gerrit.libreoffice.org/37760
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sw/inc/docary.hxx | 8 | ||||
-rw-r--r-- | sw/source/core/doc/DocumentRedlineManager.cxx | 9 | ||||
-rw-r--r-- | sw/source/core/doc/docredln.cxx | 6 |
3 files changed, 14 insertions, 9 deletions
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx index de663f105075..424680b329c6 100644 --- a/sw/inc/docary.hxx +++ b/sw/inc/docary.hxx @@ -318,6 +318,8 @@ struct CompareSwRedlineTable // Notification type for notifying about redlines to LOK clients enum class RedlineNotification { Add, Remove, Modify }; +typedef SwRangeRedline* SwRangeRedlinePtr; + class SwRedlineTable { public: @@ -333,9 +335,9 @@ public: bool Contains(const SwRangeRedline* p) const { return maVector.find(const_cast<SwRangeRedline* const>(p)) != maVector.end(); } size_type GetPos(const SwRangeRedline* p) const; - bool Insert( SwRangeRedline* p ); - bool Insert( SwRangeRedline* p, size_type& rInsPos ); - bool InsertWithValidRanges( SwRangeRedline* p, size_type* pInsPos = nullptr ); + bool Insert(SwRangeRedlinePtr& p); + bool Insert(SwRangeRedlinePtr& p, size_type& rInsPos); + bool InsertWithValidRanges(SwRangeRedlinePtr& p, size_type* pInsPos = nullptr); void Remove( size_type nPos ); bool Remove( const SwRangeRedline* p ); diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 093bdc719228..90cc40202ab8 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -1228,9 +1228,10 @@ bool DocumentRedlineManager::AppendRedline( SwRangeRedline* pNewRedl, bool bCall if( bCallDelete ) { ::comphelper::FlagGuard g(m_isForbidCompressRedlines); + //Insert may delete pNewRedl, in which case it sets pNewRedl to nullptr mpRedlineTable->Insert( pNewRedl ); m_rDoc.getIDocumentContentOperations().DeleteAndJoin( *pRedl ); - if( !mpRedlineTable->Remove( pNewRedl ) ) + if (pNewRedl && !mpRedlineTable->Remove(pNewRedl)) { assert(false); // can't happen pNewRedl = nullptr; @@ -1260,9 +1261,10 @@ bool DocumentRedlineManager::AppendRedline( SwRangeRedline* pNewRedl, bool bCall // We insert temporarily so that pNew is // also dealt with when moving the indices. ::comphelper::FlagGuard g(m_isForbidCompressRedlines); + //Insert may delete pNewRedl, in which case it sets pNewRedl to nullptr mpRedlineTable->Insert( pNewRedl ); m_rDoc.getIDocumentContentOperations().DeleteAndJoin( aPam ); - if( !mpRedlineTable->Remove( pNewRedl ) ) + if (pNewRedl && !mpRedlineTable->Remove(pNewRedl)) { assert(false); // can't happen pNewRedl = nullptr; @@ -1291,9 +1293,10 @@ bool DocumentRedlineManager::AppendRedline( SwRangeRedline* pNewRedl, bool bCall // We insert temporarily so that pNew is // also dealt with when moving the indices. ::comphelper::FlagGuard g(m_isForbidCompressRedlines); + //Insert may delete pNewRedl, in which case it sets pNewRedl to nullptr mpRedlineTable->Insert( pNewRedl ); m_rDoc.getIDocumentContentOperations().DeleteAndJoin( aPam ); - if( !mpRedlineTable->Remove( pNewRedl ) ) + if (pNewRedl && !mpRedlineTable->Remove(pNewRedl)) { assert(false); // can't happen pNewRedl = nullptr; diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 2a2272dc1fcf..709041ae486b 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -409,7 +409,7 @@ void SwRedlineTable::LOKRedlineNotification(RedlineNotification nType, SwRangeRe } } -bool SwRedlineTable::Insert( SwRangeRedline* p ) +bool SwRedlineTable::Insert(SwRangeRedlinePtr& p) { if( p->HasValidRange() ) { @@ -422,7 +422,7 @@ bool SwRedlineTable::Insert( SwRangeRedline* p ) return InsertWithValidRanges( p ); } -bool SwRedlineTable::Insert( SwRangeRedline* p, size_type& rP ) +bool SwRedlineTable::Insert(SwRangeRedlinePtr& p, size_type& rP) { if( p->HasValidRange() ) { @@ -434,7 +434,7 @@ bool SwRedlineTable::Insert( SwRangeRedline* p, size_type& rP ) return InsertWithValidRanges( p, &rP ); } -bool SwRedlineTable::InsertWithValidRanges( SwRangeRedline* p, size_type* pInsPos ) +bool SwRedlineTable::InsertWithValidRanges(SwRangeRedlinePtr& p, size_type* pInsPos) { // Create valid "sub-ranges" from the Selection bool bAnyIns = false; |