[Libreoffice-commits] core.git: Branch 'libreoffice-6-2-5' - sfx2/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sat Jun 22 02:23:42 UTC 2019


 sfx2/source/control/thumbnailview.cxx |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

New commits:
commit 7e092051d563a8454d13b6a6ecc05b93e0f0135d
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jun 19 16:26:53 2019 +0200
Commit:     Adolfo Jayme Barrientos <fitojb at ubuntu.com>
CommitDate: Sat Jun 22 04:23:06 2019 +0200

    tdf#126000 Crash deleting template
    
    regression from
        commit 72c191e046112df73c66be8dc8d1bec5a546fa60
        Date:   Wed Sep 19 12:11:38 2018 +0200
        loplugin:useuniqueptr in ThumbnailView
    
    Reviewed-on: https://gerrit.libreoffice.org/74362
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    (cherry picked from commit 801bb2d4002cf2034315875440a6aee358951eb9)
    Reviewed-on: https://gerrit.libreoffice.org/74372
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    
    Change-Id: I9bdcec5c2f14b1bd33998041d4b2d8cd2f7be052
    Reviewed-on: https://gerrit.libreoffice.org/74428
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
    Tested-by: Jenkins
    (cherry picked from commit 6efe09515c0c028c759f84275a8023f4c188437f)
    Reviewed-on: https://gerrit.libreoffice.org/74460
    Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
    Tested-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>

diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 83fae8ca76f9..df446321db0f 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -962,12 +962,16 @@ void ThumbnailView::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;
             }
         }
@@ -982,7 +986,6 @@ void ThumbnailView::RemoveItem( sal_uInt16 nItemId )
             maItemStateHdl.Call(*it);
         }
 
-        delete *it;
         mFilteredItemList.erase( it );
         mpStartSelRange = mFilteredItemList.end();
     }


More information about the Libreoffice-commits mailing list