diff options
author | ksooo <3226626+ksooo@users.noreply.github.com> | 2023-10-16 18:55:17 +0200 |
---|---|---|
committer | ksooo <3226626+ksooo@users.noreply.github.com> | 2023-10-16 19:16:17 +0200 |
commit | 04411840938ffece6fe54f66d2f36b68cd89efb6 (patch) | |
tree | 73ad639d5022354d5d2c99c758960a253956870b | |
parent | f2c831eaad896d77dd902907a4c3af914fa8328b (diff) | |
download | xbmc-04411840938ffece6fe54f66d2f36b68cd89efb6.tar.xz |
[favourites] Fix FAVOURITES_UTILS::MoveItem to ensure item gets not destructed during vector content adjustment.
-rw-r--r-- | xbmc/favourites/FavouritesUtils.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/xbmc/favourites/FavouritesUtils.cpp b/xbmc/favourites/FavouritesUtils.cpp index 5c2bdb3dd8..ef3844fdf2 100644 --- a/xbmc/favourites/FavouritesUtils.cpp +++ b/xbmc/favourites/FavouritesUtils.cpp @@ -87,15 +87,13 @@ bool MoveItem(CFileItemList& items, const std::shared_ptr<CFileItem>& item, int int nextItem = (itemPos + amount) % items.Size(); if (nextItem < 0) { - const auto& itemToAdd(item); - items.Remove(itemPos); - items.Add(itemToAdd); + items.Add(item); + items.Remove(0); } else if (nextItem == 0) { - const auto& itemToAdd(item); - items.Remove(itemPos); - items.AddFront(itemToAdd, 0); + items.AddFront(item, 0); + items.Remove(itemPos + 1); } else { |