From 7a15dcd78294cf9878e4866e4d7f5636f513a784 Mon Sep 17 00:00:00 2001 From: ksooo <3226626+ksooo@users.noreply.github.com> Date: Sun, 17 Mar 2024 09:31:19 +0100 Subject: [video] Fix regression when playing deleted movie. --- xbmc/video/windows/GUIWindowVideoBase.cpp | 35 +++++++++++++++++++++++++++++++ xbmc/video/windows/GUIWindowVideoNav.cpp | 24 +-------------------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/xbmc/video/windows/GUIWindowVideoBase.cpp b/xbmc/video/windows/GUIWindowVideoBase.cpp index 9a4c2605f6..cf98585fcd 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.cpp +++ b/xbmc/video/windows/GUIWindowVideoBase.cpp @@ -1073,6 +1073,41 @@ void CGUIWindowVideoBase::LoadPlayList(const std::string& strPlayList, bool CGUIWindowVideoBase::PlayItem(const std::shared_ptr& pItem, const std::string& player) { + if (!pItem->m_bIsFolder && pItem->IsVideoDb() && !pItem->Exists()) + { + CLog::LogF(LOGDEBUG, "File '{}' for library item '{}' doesn't exist.", pItem->GetDynPath(), + pItem->GetPath()); + + const auto profileManager{CServiceBroker::GetSettingsComponent()->GetProfileManager()}; + + if (profileManager->GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) + { + if (CGUIDialogVideoInfo::DeleteVideoItemFromDatabase(pItem, true)) + { + int itemIndex{0}; + const std::string path{pItem->GetPath()}; + for (int i = 0; i < m_vecItems->Size(); ++i) + { + if (m_vecItems->Get(i)->GetPath() == path) + { + itemIndex = i; + break; + } + } + + // update list + Refresh(true); + m_viewControl.SetSelectedItem(itemIndex); + } + } + else + { + HELPERS::ShowOKDialogText(CVariant{257}, // Error + CVariant{662}); // This file is no longer available. + } + return true; + } + //! @todo get rid of "videos with versions as folder" hack! if (pItem->m_bIsFolder && !pItem->IsPlugin() && !(pItem->HasVideoInfoTag() && pItem->GetVideoInfoTag()->IsDefaultVideoVersion())) diff --git a/xbmc/video/windows/GUIWindowVideoNav.cpp b/xbmc/video/windows/GUIWindowVideoNav.cpp index 4f246ba181..86ab1d96eb 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.cpp +++ b/xbmc/video/windows/GUIWindowVideoNav.cpp @@ -964,29 +964,7 @@ bool CGUIWindowVideoNav::OnAddMediaSource() bool CGUIWindowVideoNav::OnClick(int iItem, const std::string &player) { CFileItemPtr item = m_vecItems->Get(iItem); - if (!item->m_bIsFolder && item->IsVideoDb() && !item->Exists()) - { - CLog::Log(LOGDEBUG, "{} called on '{}' but file doesn't exist", __FUNCTION__, item->GetPath()); - - const std::shared_ptr profileManager = CServiceBroker::GetSettingsComponent()->GetProfileManager(); - - if (profileManager->GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) - { - if (!CGUIDialogVideoInfo::DeleteVideoItemFromDatabase(item, true)) - return true; - - // update list - Refresh(true); - m_viewControl.SetSelectedItem(iItem); - return true; - } - else - { - HELPERS::ShowOKDialogText(CVariant{257}, CVariant{662}); - return true; - } - } - else if (StringUtils::StartsWithNoCase(item->GetPath(), "newtag://")) + if (StringUtils::StartsWithNoCase(item->GetPath(), "newtag://")) { // dont allow update while scanning if (CVideoLibraryQueue::GetInstance().IsScanningLibrary()) -- cgit v1.2.3