Skip to content

Commit

Permalink
[video] Fix regression when playing deleted movie.
Browse files Browse the repository at this point in the history
  • Loading branch information
ksooo committed Mar 17, 2024
1 parent ac32937 commit 3d297d9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 23 deletions.
35 changes: 35 additions & 0 deletions xbmc/video/windows/GUIWindowVideoBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,41 @@ void CGUIWindowVideoBase::LoadPlayList(const std::string& strPlayList,
bool CGUIWindowVideoBase::PlayItem(const std::shared_ptr<CFileItem>& 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()))
Expand Down
24 changes: 1 addition & 23 deletions xbmc/video/windows/GUIWindowVideoNav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CProfileManager> 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())
Expand Down

0 comments on commit 3d297d9

Please sign in to comment.