diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-05-14 18:53:42 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-05-14 19:49:15 +0200 |
commit | 5031e17d4b11181be94448702b1026bd38e0b3c4 (patch) | |
tree | 2bd088acab595eb250b58ac24322f5625c426961 /sw | |
parent | 60473b5ecaa4aceef876b54c2134c4da294217e5 (diff) |
fix RenameHdl in previous commit:
::boost::ptr_vector::erase will delete the element, so p points to freed
memory after that line; try to get this to work via the transfer method.
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/ui/table/tautofmt.cxx | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/sw/source/ui/table/tautofmt.cxx b/sw/source/ui/table/tautofmt.cxx index 98c0fd48c334..3001d20af306 100644 --- a/sw/source/ui/table/tautofmt.cxx +++ b/sw/source/ui/table/tautofmt.cxx @@ -472,21 +472,22 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, RenameHdl) if( n >= pTableTbl->size() ) { - // Format mit dem Namen noch nicht vorhanden, also - // umbenennen - + // no format with this name exists, so rename it aLbFormat.RemoveEntry( nDfltStylePos + nIndex ); SwTableAutoFmt* p = &(*pTableTbl)[ nIndex ]; - pTableTbl->erase( pTableTbl->begin() + nIndex ); p->SetName( aFormatName ); - // Sortiert einfuegen!! + // keep all arrays sorted! for( n = 1; n < pTableTbl->size(); ++n ) - if( (*pTableTbl)[ n ].GetName() > aFormatName ) + if ((n != nIndex) && + ((*pTableTbl)[n].GetName() > aFormatName)) + { break; + } - pTableTbl->insert( pTableTbl->begin() + n, p ); + pTableTbl->transfer(pTableTbl->begin() + n, + pTableTbl->begin() + nIndex, *pTableTbl); aLbFormat.InsertEntry( aFormatName, nDfltStylePos + n ); aLbFormat.SelectEntryPos( nDfltStylePos + n ); |