[video] fix selection after changing video or extra art
[xbmc.git] / xbmc / pvr / PVRCachedImage.cpp
blobe336563d848cfd207f04b9d3f44640d14b5a53ac
1 /*
2 * Copyright (C) 2005-2021 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "PVRCachedImage.h"
11 #include "TextureDatabase.h"
12 #include "utils/StringUtils.h"
13 #include "utils/log.h"
15 using namespace PVR;
17 CPVRCachedImage::CPVRCachedImage(const std::string& owner) : m_owner(owner)
21 CPVRCachedImage::CPVRCachedImage(const std::string& clientImage, const std::string& owner)
22 : m_clientImage(clientImage), m_owner(owner)
24 UpdateLocalImage();
27 bool CPVRCachedImage::operator==(const CPVRCachedImage& right) const
29 return (this == &right) || (m_clientImage == right.m_clientImage &&
30 m_localImage == right.m_localImage && m_owner == right.m_owner);
33 bool CPVRCachedImage::operator!=(const CPVRCachedImage& right) const
35 return !(*this == right);
38 void CPVRCachedImage::SetClientImage(const std::string& image)
40 if (StringUtils::StartsWith(image, "image://"))
42 CLog::LogF(LOGERROR, "Not allowed to call this method with an image URL");
43 return;
46 if (m_owner.empty())
48 CLog::LogF(LOGERROR, "Empty owner");
49 return;
52 m_clientImage = image;
53 UpdateLocalImage();
56 void CPVRCachedImage::SetOwner(const std::string& owner)
58 if (m_owner != owner)
60 m_owner = owner;
61 UpdateLocalImage();
65 void CPVRCachedImage::UpdateLocalImage()
67 if (m_clientImage.empty())
68 m_localImage.clear();
69 else
70 m_localImage = CTextureUtils::GetWrappedImageURL(m_clientImage, m_owner);