Fixed the locking sequence when switching between 'Now', 'Next' and 'Schedule' in the Schedules menu

This commit is contained in:
Klaus Schmidinger 2017-06-04 09:35:18 +02:00
parent 25d28e7421
commit ec47c4f932
2 changed files with 31 additions and 22 deletions

View File

@ -9056,7 +9056,7 @@ Video Disk Recorder Revision History
- Fixed detecting the inclusion of STL header files in tools.h (thanks to Jasmin - Fixed detecting the inclusion of STL header files in tools.h (thanks to Jasmin
Jessich). Jessich).
2017-05-31: Version 2.3.6 2017-06-04: Version 2.3.6
- Added backtrace functions for debugging (see cBackTrace in thread.h). - Added backtrace functions for debugging (see cBackTrace in thread.h).
- Added checking the correct sequence of locking global lists (with help and - Added checking the correct sequence of locking global lists (with help and
@ -9100,3 +9100,5 @@ Video Disk Recorder Revision History
- Fixed a possible crash in case the SVDRP connection to a peer VDR is terminated - Fixed a possible crash in case the SVDRP connection to a peer VDR is terminated
while getting remote timers. while getting remote timers.
- Fixed the locking sequence when creating a new timer from the Schedules menu. - Fixed the locking sequence when creating a new timer from the Schedules menu.
- Fixed the locking sequence when switching between 'Now', 'Next' and 'Schedule'
in the Schedules menu.

49
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: menu.c 4.31 2017/06/03 12:49:38 kls Exp $ * $Id: menu.c 4.32 2017/06/04 09:30:56 kls Exp $
*/ */
#include "menu.h" #include "menu.h"
@ -1550,7 +1550,7 @@ private:
static int currentChannel; static int currentChannel;
static const cEvent *scheduleEvent; static const cEvent *scheduleEvent;
bool Update(void); bool Update(void);
void SetHelpKeys(void); void SetHelpKeys(const cChannels *Channels);
public: public:
cMenuWhatsOn(const cTimers *Timers, const cChannels *Channels, const cSchedules *Schedules, bool Now, int CurrentChannelNr); cMenuWhatsOn(const cTimers *Timers, const cChannels *Channels, const cSchedules *Schedules, bool Now, int CurrentChannelNr);
static int CurrentChannel(void) { return currentChannel; } static int CurrentChannel(void) { return currentChannel; }
@ -1579,7 +1579,7 @@ cMenuWhatsOn::cMenuWhatsOn(const cTimers *Timers, const cChannels *Channels, con
} }
currentChannel = CurrentChannelNr; currentChannel = CurrentChannelNr;
Display(); Display();
SetHelpKeys(); SetHelpKeys(Channels);
} }
bool cMenuWhatsOn::Update(void) bool cMenuWhatsOn::Update(void)
@ -1595,7 +1595,7 @@ bool cMenuWhatsOn::Update(void)
return result; return result;
} }
void cMenuWhatsOn::SetHelpKeys(void) void cMenuWhatsOn::SetHelpKeys(const cChannels *Channels)
{ {
cMenuScheduleItem *item = (cMenuScheduleItem *)Get(Current()); cMenuScheduleItem *item = (cMenuScheduleItem *)Get(Current());
canSwitch = false; canSwitch = false;
@ -1609,7 +1609,6 @@ void cMenuWhatsOn::SetHelpKeys(void)
NewHelpKeys |= 0x04; // "Next" NewHelpKeys |= 0x04; // "Next"
else else
NewHelpKeys |= 0x08; // "Now" NewHelpKeys |= 0x08; // "Now"
LOCK_CHANNELS_READ;
if (const cChannel *Channel = Channels->GetByChannelID(item->event->ChannelID(), true)) { if (const cChannel *Channel = Channels->GetByChannelID(item->event->ChannelID(), true)) {
if (Channel->Number() != cDevice::CurrentChannel()) { if (Channel->Number() != cDevice::CurrentChannel()) {
NewHelpKeys |= 0x10; // "Switch" NewHelpKeys |= 0x10; // "Switch"
@ -1651,7 +1650,6 @@ eOSState cMenuWhatsOn::Switch(void)
eOSState cMenuWhatsOn::Record(void) eOSState cMenuWhatsOn::Record(void)
{ {
if (cMenuScheduleItem *item = (cMenuScheduleItem *)Get(Current())) { if (cMenuScheduleItem *item = (cMenuScheduleItem *)Get(Current())) {
{
LOCK_TIMERS_WRITE; LOCK_TIMERS_WRITE;
LOCK_CHANNELS_READ; LOCK_CHANNELS_READ;
LOCK_SCHEDULES_READ; LOCK_SCHEDULES_READ;
@ -1676,12 +1674,11 @@ eOSState cMenuWhatsOn::Record(void)
// must add the timer before HandleRemoteModifications to get proper log messages with timer ids // must add the timer before HandleRemoteModifications to get proper log messages with timer ids
Timers->Del(Timer); Timers->Del(Timer);
} }
}
if (HasSubMenu()) if (HasSubMenu())
CloseSubMenu(); CloseSubMenu();
if (Update()) if (Update())
Display(); Display();
SetHelpKeys(); SetHelpKeys(Channels);
} }
return osContinue; return osContinue;
} }
@ -1716,7 +1713,8 @@ eOSState cMenuWhatsOn::ProcessKey(eKeys Key)
if (((cMenuScheduleItem *)item)->channel->Number() == cDevice::CurrentChannel()) { if (((cMenuScheduleItem *)item)->channel->Number() == cDevice::CurrentChannel()) {
SetCurrent(item); SetCurrent(item);
Display(); Display();
SetHelpKeys(); LOCK_CHANNELS_READ;
SetHelpKeys(Channels);
break; break;
} }
} }
@ -1735,8 +1733,10 @@ eOSState cMenuWhatsOn::ProcessKey(eKeys Key)
else if (!HasSubMenu()) { else if (!HasSubMenu()) {
if (HadSubMenu && Update()) if (HadSubMenu && Update())
Display(); Display();
if (Key != kNone) if (Key != kNone) {
SetHelpKeys(); LOCK_CHANNELS_READ;
SetHelpKeys(Channels);
}
} }
return state; return state;
} }
@ -1751,7 +1751,7 @@ private:
bool now, next; bool now, next;
bool canSwitch; bool canSwitch;
int helpKeys; int helpKeys;
void Set(const cChannel *Channel = NULL, bool Force = false); void Set(const cTimers *Timers, const cChannels *Channels, const cChannel *Channel = NULL, bool Force = false);
eOSState Number(void); eOSState Number(void);
eOSState Record(void); eOSState Record(void);
eOSState Switch(void); eOSState Switch(void);
@ -1777,7 +1777,9 @@ cMenuSchedule::cMenuSchedule(void)
helpKeys = 0; helpKeys = 0;
cMenuScheduleItem::SetSortMode(cMenuScheduleItem::ssmAllThis); cMenuScheduleItem::SetSortMode(cMenuScheduleItem::ssmAllThis);
cMenuWhatsOn::SetCurrentChannel(cDevice::CurrentChannel()); cMenuWhatsOn::SetCurrentChannel(cDevice::CurrentChannel());
Set(NULL, true); LOCK_TIMERS_READ;
LOCK_CHANNELS_READ;
Set(Timers, Channels, NULL, true);
} }
cMenuSchedule::~cMenuSchedule() cMenuSchedule::~cMenuSchedule()
@ -1785,14 +1787,12 @@ cMenuSchedule::~cMenuSchedule()
cMenuWhatsOn::ScheduleEvent(); // makes sure any posted data is cleared cMenuWhatsOn::ScheduleEvent(); // makes sure any posted data is cleared
} }
void cMenuSchedule::Set(const cChannel *Channel, bool Force) void cMenuSchedule::Set(const cTimers *Timers, const cChannels *Channels, const cChannel *Channel, bool Force)
{ {
if (Force) { if (Force) {
schedulesStateKey.Reset(); schedulesStateKey.Reset();
scheduleState = -1; scheduleState = -1;
} }
LOCK_TIMERS_READ;
LOCK_CHANNELS_READ;
if (const cSchedules *Schedules = cSchedules::GetSchedulesRead(schedulesStateKey)) { if (const cSchedules *Schedules = cSchedules::GetSchedulesRead(schedulesStateKey)) {
cMenuScheduleItem *CurrentItem = (cMenuScheduleItem *)Get(Current()); cMenuScheduleItem *CurrentItem = (cMenuScheduleItem *)Get(Current());
const cEvent *Event = NULL; const cEvent *Event = NULL;
@ -1942,7 +1942,9 @@ void cMenuSchedule::SetHelpKeys(void)
eOSState cMenuSchedule::Number(void) eOSState cMenuSchedule::Number(void)
{ {
cMenuScheduleItem::IncSortMode(); cMenuScheduleItem::IncSortMode();
Set(NULL, true); LOCK_TIMERS_READ;
LOCK_CHANNELS_READ;
Set(Timers, Channels, NULL, true);
return osContinue; return osContinue;
} }
@ -2003,8 +2005,11 @@ eOSState cMenuSchedule::Switch(void)
eOSState cMenuSchedule::ProcessKey(eKeys Key) eOSState cMenuSchedule::ProcessKey(eKeys Key)
{ {
if (!HasSubMenu()) if (!HasSubMenu()) {
Set(); // react on any changes to the schedules list LOCK_TIMERS_READ;
LOCK_CHANNELS_READ;
Set(Timers, Channels); // react on any changes to the schedules list
}
bool HadSubMenu = HasSubMenu(); bool HadSubMenu = HasSubMenu();
eOSState state = cOsdMenu::ProcessKey(Key); eOSState state = cOsdMenu::ProcessKey(Key);
@ -2043,9 +2048,10 @@ eOSState cMenuSchedule::ProcessKey(eKeys Key)
case kChanUp: case kChanUp:
case kChanDn|k_Repeat: case kChanDn|k_Repeat:
case kChanDn: if (!HasSubMenu()) { case kChanDn: if (!HasSubMenu()) {
LOCK_TIMERS_READ;
LOCK_CHANNELS_READ; LOCK_CHANNELS_READ;
if (const cChannel *Channel = Channels->GetByNumber(cDevice::CurrentChannel())) if (const cChannel *Channel = Channels->GetByNumber(cDevice::CurrentChannel()))
Set(Channel, true); Set(Timers, Channels, Channel, true);
} }
break; break;
case kInfo: case kInfo:
@ -2062,10 +2068,11 @@ eOSState cMenuSchedule::ProcessKey(eKeys Key)
else if (!HasSubMenu()) { else if (!HasSubMenu()) {
now = next = false; now = next = false;
if (const cEvent *ei = cMenuWhatsOn::ScheduleEvent()) { if (const cEvent *ei = cMenuWhatsOn::ScheduleEvent()) {
LOCK_TIMERS_READ;
LOCK_CHANNELS_READ; LOCK_CHANNELS_READ;
if (const cChannel *Channel = Channels->GetByChannelID(ei->ChannelID(), true)) { if (const cChannel *Channel = Channels->GetByChannelID(ei->ChannelID(), true)) {
cMenuScheduleItem::SetSortMode(cMenuScheduleItem::ssmAllThis); cMenuScheduleItem::SetSortMode(cMenuScheduleItem::ssmAllThis);
Set(Channel, true); Set(Timers, Channels, Channel, true);
} }
} }
else if (HadSubMenu && Update()) else if (HadSubMenu && Update())