Permalink
Browse files

fix conversion from invalid CDateTime objects to strings (fixes #12936)

  • Loading branch information...
1 parent 81e874f commit 5bd84949895eb4ce5cbaef0b775e18ffd1debc98 @Montellese Montellese committed Apr 18, 2012
Showing with 32 additions and 15 deletions.
  1. +28 −11 xbmc/GUIInfoManager.cpp
  2. +4 −4 xbmc/video/VideoInfoTag.cpp
View
@@ -3377,10 +3377,15 @@ CStdString CGUIInfoManager::GetVideoLabel(int item)
break;
case VIDEOPLAYER_PREMIERED:
{
+ CDateTime dateTime;
if (m_currentFile->GetVideoInfoTag()->m_firstAired.IsValid())
- return m_currentFile->GetVideoInfoTag()->m_firstAired.GetAsLocalizedDate();
- if (m_currentFile->GetVideoInfoTag()->m_premiered.IsValid())
- return m_currentFile->GetVideoInfoTag()->m_premiered.GetAsLocalizedDate();
+ dateTime = m_currentFile->GetVideoInfoTag()->m_firstAired;
+ else if (m_currentFile->GetVideoInfoTag()->m_premiered.IsValid())
+ dateTime = m_currentFile->GetVideoInfoTag()->m_premiered;
+
+ if (dateTime.IsValid())
+ return dateTime.GetAsLocalizedDate();
+ break;
}
break;
case VIDEOPLAYER_PLOT:
@@ -3439,7 +3444,11 @@ CStdString CGUIInfoManager::GetVideoLabel(int item)
case VIDEOPLAYER_TAGLINE:
return m_currentFile->GetVideoInfoTag()->m_strTagLine;
case VIDEOPLAYER_LASTPLAYED:
- return m_currentFile->GetVideoInfoTag()->m_lastPlayed.GetAsLocalizedDateTime();
+ {
+ if (m_currentFile->GetVideoInfoTag()->m_lastPlayed.IsValid())
+ return m_currentFile->GetVideoInfoTag()->m_lastPlayed.GetAsLocalizedDateTime();
+ break;
+ }
case VIDEOPLAYER_PLAYCOUNT:
{
CStdString strPlayCount;
@@ -3871,11 +3880,14 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, CStdSt
}
case LISTITEM_LASTPLAYED:
{
- CStdString strLastPlayed;
+ CDateTime dateTime;
if (item->HasVideoInfoTag())
- return item->GetVideoInfoTag()->m_lastPlayed.GetAsLocalizedDate();
- if (item->HasMusicInfoTag())
- return item->GetMusicInfoTag()->GetLastPlayed().GetAsLocalizedDate();
+ dateTime = item->GetVideoInfoTag()->m_lastPlayed;
+ else if (item->HasMusicInfoTag())
+ dateTime = item->GetMusicInfoTag()->GetLastPlayed();
+
+ if (dateTime.IsValid())
+ return dateTime.GetAsLocalizedDate();
break;
}
case LISTITEM_TRACKNUMBER:
@@ -3926,10 +3938,15 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, CStdSt
case LISTITEM_PREMIERED:
if (item->HasVideoInfoTag())
{
+ CDateTime dateTime;
if (item->GetVideoInfoTag()->m_firstAired.IsValid())
- return item->GetVideoInfoTag()->m_firstAired.GetAsLocalizedDate();
- if (item->GetVideoInfoTag()->m_premiered.IsValid())
- return item->GetVideoInfoTag()->m_premiered.GetAsLocalizedDate();
+ dateTime = item->GetVideoInfoTag()->m_firstAired;
+ else if (item->GetVideoInfoTag()->m_premiered.IsValid())
+ dateTime = item->GetVideoInfoTag()->m_premiered;
+
+ if (dateTime.IsValid())
+ return dateTime.GetAsLocalizedDate();
+ break;
}
break;
case LISTITEM_GENRE:
@@ -443,15 +443,15 @@ void CVideoInfoTag::Serialize(CVariant& value)
value["originaltitle"] = m_strOriginalTitle;
value["sorttitle"] = m_strSortTitle;
value["episodeguide"] = m_strEpisodeGuide;
- value["premiered"] = m_premiered.GetAsDBDate();
+ value["premiered"] = m_premiered.IsValid() ? m_premiered.GetAsDBDate() : StringUtils::EmptyString;
value["status"] = m_strStatus;
value["productioncode"] = m_strProductionCode;
- value["firstaired"] = m_firstAired.GetAsDBDate();
+ value["firstaired"] = m_firstAired.IsValid() ? m_firstAired.GetAsDBDate() : StringUtils::EmptyString;
value["showtitle"] = m_strShowTitle;
value["album"] = m_strAlbum;
value["artist"] = m_strArtist;
value["playcount"] = m_playCount;
- value["lastplayed"] = m_lastPlayed.GetAsDBDateTime();
+ value["lastplayed"] = m_lastPlayed.IsValid() ? m_lastPlayed.GetAsDBDateTime() : StringUtils::EmptyString;
value["top250"] = m_iTop250;
value["year"] = m_iYear;
value["season"] = m_iSeason;
@@ -468,7 +468,7 @@ void CVideoInfoTag::Serialize(CVariant& value)
value["resume"] = resume;
value["tvshowid"] = m_iIdShow;
value["tvshowpath"] = m_strShowPath;
- value["dateadded"] = m_dateAdded.IsValid() ? m_dateAdded.GetAsDBDateTime() : "";
+ value["dateadded"] = m_dateAdded.IsValid() ? m_dateAdded.GetAsDBDateTime() : StringUtils::EmptyString;
}
const CStdString CVideoInfoTag::GetCast(bool bIncludeRole /*= false*/) const

0 comments on commit 5bd8494

Please sign in to comment.