summaryrefslogtreecommitdiff
path: root/sfx2/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-06-19 16:26:53 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-06-19 19:23:26 +0200
commit801bb2d4002cf2034315875440a6aee358951eb9 (patch)
treec602acf1c486548b3add3316c08d13e2c7fb2874 /sfx2/source
parente2589f4584efcf0306ab69f7223abdd7469e3604 (diff)
tdf#126000 Crash deleting template
regression from commit 72c191e046112df73c66be8dc8d1bec5a546fa60 Date: Wed Sep 19 12:11:38 2018 +0200 loplugin:useuniqueptr in ThumbnailView Change-Id: I9bdcec5c2f14b1bd33998041d4b2d8cd2f7be052 Reviewed-on: https://gerrit.libreoffice.org/74362 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2/source')
-rw-r--r--sfx2/source/control/thumbnailview.cxx11
1 files changed, 7 insertions, 4 deletions
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 5a9027829edb..f9cbbae6027a 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -2066,12 +2066,16 @@ void SfxThumbnailView::RemoveItem( sal_uInt16 nItemId )
if ( nPos < mFilteredItemList.size() ) {
+ // keep it alive until after we have deleted it from the filter item list
+ std::unique_ptr<ThumbnailViewItem> xKeepAliveViewItem;
+
// delete item from the thumbnail list
- for (size_t i = 0, n = mItemList.size(); i < n; ++i)
+ for (auto it = mItemList.begin(); it != mItemList.end(); ++it)
{
- if (mItemList[i]->mnId == nItemId)
+ if ((*it)->mnId == nItemId)
{
- mItemList.erase(mItemList.begin()+i);
+ xKeepAliveViewItem = std::move(*it);
+ mItemList.erase(it);
break;
}
}
@@ -2086,7 +2090,6 @@ void SfxThumbnailView::RemoveItem( sal_uInt16 nItemId )
maItemStateHdl.Call(*it);
}
- delete *it;
mFilteredItemList.erase( it );
mpStartSelRange = mFilteredItemList.end();
}