diff options
author | CrystalP <crystalp@kodi.tv> | 2024-03-03 05:33:54 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-03 05:33:54 -0500 |
commit | 8404b9f510f84b7416f5ff3f2bc7567a93d3dbb6 (patch) | |
tree | 54e8cac7501dda0dc0fafabc1346e2e9ee49a513 | |
parent | 4c7f977c9516074e46e8b0e9438189921be550c6 (diff) | |
parent | 169150fa407de2550df0d3692977f85014ce6f25 (diff) |
Merge pull request #24791 from CrystalP/fix-removedselecteditem
[video] fix selected item after removing version/extra
-rw-r--r-- | xbmc/video/dialogs/GUIDialogVideoManager.cpp | 19 | ||||
-rw-r--r-- | xbmc/video/dialogs/GUIDialogVideoManager.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/xbmc/video/dialogs/GUIDialogVideoManager.cpp b/xbmc/video/dialogs/GUIDialogVideoManager.cpp index 344d338d72..6d01ddc22b 100644 --- a/xbmc/video/dialogs/GUIDialogVideoManager.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoManager.cpp @@ -305,6 +305,7 @@ void CGUIDialogVideoManager::Remove() // refresh data and controls Refresh(); + RefreshSelectedVideoAsset(); UpdateControls(); } @@ -466,3 +467,21 @@ void CGUIDialogVideoManager::AppendItemFolderToFileBrowserSources( sources.emplace_back(itemSource); } } + +void CGUIDialogVideoManager::RefreshSelectedVideoAsset() +{ + if (!m_selectedVideoAsset || !m_selectedVideoAsset->HasVideoInfoTag() || + !m_videoAssetsList->Size()) + { + m_selectedVideoAsset = std::make_shared<CFileItem>(); + return; + } + + const int dbId{m_selectedVideoAsset->GetVideoInfoTag()->m_iDbId}; + const auto it{std::find_if(m_videoAssetsList->cbegin(), m_videoAssetsList->cend(), + [dbId](const auto& entry) + { return entry->GetVideoInfoTag()->m_iDbId == dbId; })}; + + if (it == m_videoAssetsList->cend()) + m_selectedVideoAsset = m_videoAssetsList->Get(0); +} diff --git a/xbmc/video/dialogs/GUIDialogVideoManager.h b/xbmc/video/dialogs/GUIDialogVideoManager.h index 6248c76c10..b4b043df0a 100644 --- a/xbmc/video/dialogs/GUIDialogVideoManager.h +++ b/xbmc/video/dialogs/GUIDialogVideoManager.h @@ -56,6 +56,7 @@ protected: VideoAssetType assetType, const std::string& defaultName); void AppendItemFolderToFileBrowserSources(std::vector<CMediaSource>& sources); + void RefreshSelectedVideoAsset(); CVideoDatabase m_database; std::shared_ptr<CFileItem> m_videoAsset; |