diff options
author | ksooo <3226626+ksooo@users.noreply.github.com> | 2023-11-26 14:16:38 +0100 |
---|---|---|
committer | ksooo <3226626+ksooo@users.noreply.github.com> | 2023-12-06 12:59:34 +0100 |
commit | e893985c0700fd736666d14f19fc18f97e424076 (patch) | |
tree | 4170a3d961b0fca3ac758f1df621238b8cef52f3 | |
parent | 9316a52bff32042f76f0ce544c0741cc7a99d360 (diff) |
[video] CVideoSelectActionProcessorBase: make m_item a std::shared_ptr.
-rw-r--r-- | xbmc/favourites/GUIWindowFavourites.cpp | 19 | ||||
-rw-r--r-- | xbmc/listproviders/DirectoryProvider.cpp | 21 | ||||
-rw-r--r-- | xbmc/pvr/windows/GUIWindowPVRRecordings.cpp | 15 | ||||
-rw-r--r-- | xbmc/video/guilib/VideoSelectActionProcessor.cpp | 6 | ||||
-rw-r--r-- | xbmc/video/guilib/VideoSelectActionProcessor.h | 6 | ||||
-rw-r--r-- | xbmc/video/windows/GUIWindowVideoBase.cpp | 12 |
6 files changed, 42 insertions, 37 deletions
diff --git a/xbmc/favourites/GUIWindowFavourites.cpp b/xbmc/favourites/GUIWindowFavourites.cpp index f47bf6e93e..25989b364a 100644 --- a/xbmc/favourites/GUIWindowFavourites.cpp +++ b/xbmc/favourites/GUIWindowFavourites.cpp @@ -50,43 +50,46 @@ namespace class CVideoSelectActionProcessor : public VIDEO::GUILIB::CVideoSelectActionProcessorBase { public: - explicit CVideoSelectActionProcessor(CFileItem& item) : CVideoSelectActionProcessorBase(item) {} + explicit CVideoSelectActionProcessor(const std::shared_ptr<CFileItem>& item) + : CVideoSelectActionProcessorBase(item) + { + } protected: bool OnPlayPartSelected(unsigned int part) override { // part numbers are 1-based FAVOURITES_UTILS::ExecuteAction( - {"PlayMedia", m_item, StringUtils::Format("playoffset={}", part - 1)}); + {"PlayMedia", *m_item, StringUtils::Format("playoffset={}", part - 1)}); return true; } bool OnResumeSelected() override { - FAVOURITES_UTILS::ExecuteAction({"PlayMedia", m_item, "resume"}); + FAVOURITES_UTILS::ExecuteAction({"PlayMedia", *m_item, "resume"}); return true; } bool OnPlaySelected() override { - FAVOURITES_UTILS::ExecuteAction({"PlayMedia", m_item, "noresume"}); + FAVOURITES_UTILS::ExecuteAction({"PlayMedia", *m_item, "noresume"}); return true; } bool OnQueueSelected() override { - FAVOURITES_UTILS::ExecuteAction({"QueueMedia", m_item, ""}); + FAVOURITES_UTILS::ExecuteAction({"QueueMedia", *m_item, ""}); return true; } bool OnInfoSelected() override { - return UTILS::GUILIB::CGUIContentUtils::ShowInfoForItem(m_item); + return UTILS::GUILIB::CGUIContentUtils::ShowInfoForItem(*m_item); } bool OnMoreSelected() override { - CONTEXTMENU::ShowFor(std::make_shared<CFileItem>(m_item), CContextMenuManager::MAIN); + CONTEXTMENU::ShowFor(m_item, CContextMenuManager::MAIN); return true; } }; @@ -135,7 +138,7 @@ bool CGUIWindowFavourites::OnSelect(int itemIdx) // video select action setting is for files only, except exec func is playmedia... if (targetItem.HasVideoInfoTag() && (!targetItem.m_bIsFolder || isPlayMedia)) { - CVideoSelectActionProcessor proc{targetItem}; + CVideoSelectActionProcessor proc{std::make_shared<CFileItem>(targetItem)}; if (proc.Process()) return true; } diff --git a/xbmc/listproviders/DirectoryProvider.cpp b/xbmc/listproviders/DirectoryProvider.cpp index 598a8d685d..a7ba3592d2 100644 --- a/xbmc/listproviders/DirectoryProvider.cpp +++ b/xbmc/listproviders/DirectoryProvider.cpp @@ -475,7 +475,7 @@ bool ExecuteAction(const CExecString& execute) class CVideoSelectActionProcessor : public VIDEO::GUILIB::CVideoSelectActionProcessorBase { public: - CVideoSelectActionProcessor(CDirectoryProvider& provider, CFileItem& item) + CVideoSelectActionProcessor(CDirectoryProvider& provider, const std::shared_ptr<CFileItem>& item) : CVideoSelectActionProcessorBase(item), m_provider(provider) { } @@ -484,49 +484,48 @@ protected: bool OnPlayPartSelected(unsigned int part) override { // part numbers are 1-based - ExecuteAction({"PlayMedia", m_item, StringUtils::Format("playoffset={}", part - 1)}); + ExecuteAction({"PlayMedia", *m_item, StringUtils::Format("playoffset={}", part - 1)}); return true; } bool OnResumeSelected() override { - ExecuteAction({"PlayMedia", m_item, "resume"}); + ExecuteAction({"PlayMedia", *m_item, "resume"}); return true; } bool OnPlaySelected() override { //! @todo get rid of special handling for movie versions - if (m_item.GetVideoInfoTag()->m_type == MediaTypeMovie) + if (m_item->GetVideoInfoTag()->m_type == MediaTypeMovie) { - auto videoItem = std::make_shared<CFileItem>(m_item); CGUIDialogVideoVersion::PlayVideoVersion( - videoItem, + m_item, [](const std::shared_ptr<CFileItem>& item) { ExecuteAction({"PlayMedia", *item.get(), "noresume"}); }); } else - ExecuteAction({"PlayMedia", m_item, "noresume"}); + ExecuteAction({"PlayMedia", *m_item, "noresume"}); return true; } bool OnQueueSelected() override { - ExecuteAction({"QueueMedia", m_item, ""}); + ExecuteAction({"QueueMedia", *m_item, ""}); return true; } bool OnInfoSelected() override { - m_provider.OnInfo(std::make_shared<CFileItem>(m_item)); + m_provider.OnInfo(m_item); return true; } bool OnMoreSelected() override { - m_provider.OnContextMenu(std::make_shared<CFileItem>(m_item)); + m_provider.OnContextMenu(m_item); return true; } @@ -587,7 +586,7 @@ bool CDirectoryProvider::OnClick(const CGUIListItemPtr& item) // video select action setting is for files only, except exec func is playmedia... if (targetItem.HasVideoInfoTag() && (!targetItem.m_bIsFolder || isPlayMedia)) { - CVideoSelectActionProcessor proc{*this, targetItem}; + CVideoSelectActionProcessor proc{*this, std::make_shared<CFileItem>(targetItem)}; if (proc.Process()) return true; } diff --git a/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp b/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp index 0764f4e33d..a1164e640f 100644 --- a/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp @@ -227,7 +227,9 @@ namespace class CVideoSelectActionProcessor : public VIDEO::GUILIB::CVideoSelectActionProcessorBase { public: - CVideoSelectActionProcessor(CGUIWindowPVRRecordingsBase& window, CFileItem& item, int itemIndex) + CVideoSelectActionProcessor(CGUIWindowPVRRecordingsBase& window, + const std::shared_ptr<CFileItem>& item, + int itemIndex) : CVideoSelectActionProcessorBase(item), m_window(window), m_itemIndex(itemIndex) { } @@ -242,27 +244,26 @@ protected: bool OnResumeSelected() override { CServiceBroker::GetPVRManager().Get<PVR::GUI::Playback>().ResumePlayRecording( - m_item, true /* fall back to play if no resume possible */); + *m_item, true /* fall back to play if no resume possible */); return true; } bool OnPlaySelected() override { CServiceBroker::GetPVRManager().Get<PVR::GUI::Playback>().PlayRecording( - m_item, false /* no resume check */); + *m_item, false /* no resume check */); return true; } bool OnQueueSelected() override { - VIDEO_UTILS::QueueItem(std::make_shared<CFileItem>(m_item), - VIDEO_UTILS::QueuePosition::POSITION_END); + VIDEO_UTILS::QueueItem(m_item, VIDEO_UTILS::QueuePosition::POSITION_END); return true; } bool OnInfoSelected() override { - CServiceBroker::GetPVRManager().Get<PVR::GUI::Recordings>().ShowRecordingInfo(m_item); + CServiceBroker::GetPVRManager().Get<PVR::GUI::Recordings>().ShowRecordingInfo(*m_item); return true; } @@ -359,7 +360,7 @@ bool CGUIWindowPVRRecordingsBase::OnMessage(CGUIMessage& message) } else { - CVideoSelectActionProcessor proc(*this, *item, iItem); + CVideoSelectActionProcessor proc(*this, item, iItem); bReturn = proc.Process(); } break; diff --git a/xbmc/video/guilib/VideoSelectActionProcessor.cpp b/xbmc/video/guilib/VideoSelectActionProcessor.cpp index 1a8d274a4f..dfb6e2eabe 100644 --- a/xbmc/video/guilib/VideoSelectActionProcessor.cpp +++ b/xbmc/video/guilib/VideoSelectActionProcessor.cpp @@ -50,7 +50,7 @@ bool CVideoSelectActionProcessorBase::Process(SelectAction selectAction) case SELECT_ACTION_PLAY_OR_RESUME: { - const SelectAction action = ChoosePlayOrResume(m_item); + const SelectAction action = ChoosePlayOrResume(*m_item); if (action < 0) return true; // User cancelled the select menu. We're done. @@ -90,7 +90,7 @@ bool CVideoSelectActionProcessorBase::Process(SelectAction selectAction) unsigned int CVideoSelectActionProcessorBase::ChooseStackItemPartNumber() const { CFileItemList parts; - XFILE::CDirectory::GetDirectory(m_item.GetDynPath(), parts, "", XFILE::DIR_FLAG_DEFAULTS); + XFILE::CDirectory::GetDirectory(m_item->GetDynPath(), parts, "", XFILE::DIR_FLAG_DEFAULTS); for (int i = 0; i < parts.Size(); ++i) parts[i]->SetLabel(StringUtils::Format(g_localizeStrings.Get(23051), i + 1)); // Part # @@ -132,7 +132,7 @@ SelectAction CVideoSelectActionProcessorBase::ChooseVideoItemSelectAction() cons { CContextButtons choices; - const std::string resumeString = VIDEO_UTILS::GetResumeString(m_item); + const std::string resumeString = VIDEO_UTILS::GetResumeString(*m_item); if (!resumeString.empty()) { choices.Add(SELECT_ACTION_RESUME, resumeString); diff --git a/xbmc/video/guilib/VideoSelectActionProcessor.h b/xbmc/video/guilib/VideoSelectActionProcessor.h index c896a386da..52d01b0846 100644 --- a/xbmc/video/guilib/VideoSelectActionProcessor.h +++ b/xbmc/video/guilib/VideoSelectActionProcessor.h @@ -10,6 +10,8 @@ #include "video/guilib/VideoSelectAction.h" +#include <memory> + class CFileItem; namespace VIDEO @@ -19,7 +21,7 @@ namespace GUILIB class CVideoSelectActionProcessorBase { public: - explicit CVideoSelectActionProcessorBase(CFileItem& item) : m_item(item) {} + explicit CVideoSelectActionProcessorBase(const std::shared_ptr<CFileItem>& item) : m_item(item) {} virtual ~CVideoSelectActionProcessorBase() = default; static SelectAction GetDefaultSelectAction(); @@ -37,7 +39,7 @@ protected: virtual bool OnInfoSelected() = 0; virtual bool OnMoreSelected() = 0; - CFileItem& m_item; + std::shared_ptr<CFileItem> m_item; private: CVideoSelectActionProcessorBase() = delete; diff --git a/xbmc/video/windows/GUIWindowVideoBase.cpp b/xbmc/video/windows/GUIWindowVideoBase.cpp index d042404f8c..3aef9de39f 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.cpp +++ b/xbmc/video/windows/GUIWindowVideoBase.cpp @@ -543,7 +543,7 @@ class CVideoSelectActionProcessor : public CVideoSelectActionProcessorBase { public: CVideoSelectActionProcessor(CGUIWindowVideoBase& window, - CFileItem& item, + const std::shared_ptr<CFileItem>& item, int itemIndex, const std::string& player) : CVideoSelectActionProcessorBase(item), @@ -553,7 +553,7 @@ public: { // Reset the current start offset. The actual resume // option is set by the processor, based on the action passed. - m_item.SetStartOffset(0); + m_item->SetStartOffset(0); } protected: @@ -564,8 +564,8 @@ protected: bool OnResumeSelected() override { - m_item.SetStartOffset(STARTOFFSET_RESUME); - if (m_item.m_bIsFolder) + m_item->SetStartOffset(STARTOFFSET_RESUME); + if (m_item->m_bIsFolder) { // resume playback of the folder m_window.PlayItem(m_itemIndex, m_player); @@ -577,7 +577,7 @@ protected: bool OnPlaySelected() override { - if (m_item.m_bIsFolder) + if (m_item->m_bIsFolder) { // play the folder m_window.PlayItem(m_itemIndex, m_player); @@ -614,7 +614,7 @@ bool CGUIWindowVideoBase::OnFileAction(int iItem, SelectAction action, const std if (!item) return false; - CVideoSelectActionProcessor proc(*this, *item, iItem, player); + CVideoSelectActionProcessor proc(*this, item, iItem, player); return proc.Process(action); } |