diff options
author | Ivan Timofeev <timofeev.i.s@gmail.com> | 2013-07-29 21:43:59 +0400 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-07-29 22:17:58 +0200 |
commit | c7bab3002a967b39b1d7be06dfa20fca9fd9f837 (patch) | |
tree | 692ffebceed0a5583df435b95349c9eb6eb1e2d4 | |
parent | acc7484b0fd1d5df2a709399bcdf03ec81943e71 (diff) |
fdo#67467: fix crash when renaming table in AutoFormat dialog
this reverts 5031e17d4b11181be94448702b1026bd38e0b3c4 and uses
ptr_vector::release instead of ptr_vector::erase to prevent object deletion.
The use of "transfer" leads to "Assertion `(void*)&from != (void*)this' failed".
Change-Id: I77467ce9e1d9dd4b833032ebbe920cbb34d36675
Reviewed-on: https://gerrit.libreoffice.org/5172
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
(cherry picked from commit 2f527be5513159c0aebd93f356cbd2b1dc04b253)
Signed-off-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r-- | sw/inc/tblafmt.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/tblafmt.cxx | 5 | ||||
-rw-r--r-- | sw/source/ui/table/tautofmt.cxx | 7 |
3 files changed, 6 insertions, 8 deletions
diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx index 029d4447095e..bac0e22e4f8d 100644 --- a/sw/inc/tblafmt.hxx +++ b/sw/inc/tblafmt.hxx @@ -314,7 +314,7 @@ public: SwTableAutoFmt & operator[](size_t i); void InsertAutoFmt(size_t i, SwTableAutoFmt * pFmt); void EraseAutoFmt(size_t i); - void MoveAutoFmt(size_t target, size_t source); + SwTableAutoFmt* ReleaseAutoFmt(size_t i); sal_Bool Load(); sal_Bool Save() const; diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx index ea1630c14cf8..2dee48589815 100644 --- a/sw/source/core/doc/tblafmt.cxx +++ b/sw/source/core/doc/tblafmt.cxx @@ -1048,10 +1048,9 @@ void SwTableAutoFmtTbl::EraseAutoFmt(size_t const i) m_pImpl->m_AutoFormats.erase(m_pImpl->m_AutoFormats.begin() + i); } -void SwTableAutoFmtTbl::MoveAutoFmt(size_t const target, size_t source) +SwTableAutoFmt* SwTableAutoFmtTbl::ReleaseAutoFmt(size_t const i) { - m_pImpl->m_AutoFormats.transfer(m_pImpl->m_AutoFormats.begin() + target, - m_pImpl->m_AutoFormats.begin() + source, m_pImpl->m_AutoFormats); + return m_pImpl->m_AutoFormats.release(m_pImpl->m_AutoFormats.begin() + i).release(); } SwTableAutoFmtTbl::~SwTableAutoFmtTbl() diff --git a/sw/source/ui/table/tautofmt.cxx b/sw/source/ui/table/tautofmt.cxx index 8995ac076a78..4c5cc3640869 100644 --- a/sw/source/ui/table/tautofmt.cxx +++ b/sw/source/ui/table/tautofmt.cxx @@ -437,19 +437,18 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, RenameHdl) { // no format with this name exists, so rename it m_pLbFormat->RemoveEntry( nDfltStylePos + nIndex ); - SwTableAutoFmt* p = &(*pTableTbl)[ nIndex ]; + SwTableAutoFmt* p = pTableTbl->ReleaseAutoFmt( nIndex ); p->SetName( aFormatName ); // keep all arrays sorted! for( n = 1; n < pTableTbl->size(); ++n ) - if ((n != nIndex) && - ((*pTableTbl)[n].GetName() > aFormatName)) + if ((*pTableTbl)[n].GetName() > aFormatName) { break; } - pTableTbl->MoveAutoFmt(n, nIndex); + pTableTbl->InsertAutoFmt( n, p ); m_pLbFormat->InsertEntry( aFormatName, nDfltStylePos + n ); m_pLbFormat->SelectEntryPos( nDfltStylePos + n ); |