Skip to content

Commit

Permalink
Merge pull request #8962 from ksooo/jarvis-trac16539
Browse files Browse the repository at this point in the history
[PVR] Fix crash after selecting 'Add timer' in PVR timer window, closes Trac16539
  • Loading branch information
MartijnKaijser committed Jan 28, 2016
2 parents ad93e7e + e15ed4c commit 46175d6
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 3 deletions.
14 changes: 14 additions & 0 deletions xbmc/pvr/addons/PVRClients.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,20 @@ bool CPVRClients::GetClient(const std::string &strId, AddonPtr &addon) const
return false;
}

bool CPVRClients::SupportsTimers() const
{
PVR_CLIENTMAP clients;
GetConnectedClients(clients);

for (const auto &entry : clients)
{
if (entry.second->SupportsTimers())
return true;
}

return false;
}

bool CPVRClients::SupportsChannelGroups(int iClientId) const
{
PVR_CLIENT client;
Expand Down
6 changes: 6 additions & 0 deletions xbmc/pvr/addons/PVRClients.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ namespace PVR
/*! @name Timer methods */
//@{

/*!
* @brief Check whether there is at least one connected client supporting timers.
* @return True if at least one connected client supports timers, false otherwise.
*/
bool SupportsTimers() const;

/*!
* @brief Check whether a client supports timers.
* @param iClientId The id of the client to check.
Expand Down
2 changes: 1 addition & 1 deletion xbmc/pvr/windows/GUIWindowPVRChannels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void CGUIWindowPVRChannels::GetContextButtons(int itemNumber, CContextButtons &b

if (channel->IsRecording())
buttons.Add(CONTEXT_BUTTON_STOP_RECORD, 19059); /* Stop recording */
else
else if (g_PVRClients->SupportsTimers(channel->ClientID()))
buttons.Add(CONTEXT_BUTTON_START_RECORD, 264); /* Record */

if (ActiveAE::CActiveAEDSP::GetInstance().IsProcessing())
Expand Down
2 changes: 1 addition & 1 deletion xbmc/pvr/windows/GUIWindowPVRGuide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void CGUIWindowPVRGuide::GetContextButtons(int itemNumber, CContextButtons &butt
buttons.Add(CONTEXT_BUTTON_DELETE_TIMER, 19060); /* Delete timer */
}
}
else if (epg->EndAsLocalTime() > CDateTime::GetCurrentDateTime())
else if (g_PVRClients->SupportsTimers() && epg->EndAsLocalTime() > CDateTime::GetCurrentDateTime())
{
buttons.Add(CONTEXT_BUTTON_START_RECORD, 264); /* Record */
buttons.Add(CONTEXT_BUTTON_ADD_TIMER, 19061); /* Add timer */
Expand Down
2 changes: 1 addition & 1 deletion xbmc/pvr/windows/GUIWindowPVRSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void CGUIWindowPVRSearch::GetContextButtons(int itemNumber, CContextButtons &but
buttons.Add(CONTEXT_BUTTON_DELETE_TIMER, 19060); /* Delete timer */
}
}
else if (epg->EndAsLocalTime() > CDateTime::GetCurrentDateTime())
else if (g_PVRClients->SupportsTimers() && epg->EndAsLocalTime() > CDateTime::GetCurrentDateTime())
{
buttons.Add(CONTEXT_BUTTON_START_RECORD, 264); /* Record */
buttons.Add(CONTEXT_BUTTON_ADD_TIMER, 19061); /* Add timer */
Expand Down
6 changes: 6 additions & 0 deletions xbmc/pvr/windows/GUIWindowPVRTimers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,12 @@ bool CGUIWindowPVRTimers::ActionDeleteTimer(CFileItem *item)

bool CGUIWindowPVRTimers::ActionShowTimer(CFileItem *item)
{
if (!g_PVRClients->SupportsTimers())
{
CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19215}); // "Information", "The PVR backend does not support timers."
return false;
}

bool bReturn = false;

/* Check if "Add timer..." entry is pressed by OK, if yes
Expand Down

0 comments on commit 46175d6

Please sign in to comment.