summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann Friedrichs <johann.friedrichs@web.de>2017-06-13 21:09:22 (GMT)
committerFrank Neumann <fnu@yavdr.org>2017-06-13 21:09:22 (GMT)
commitceb158e1bd9df3cc0c6f9243856faac6f735ffb8 (patch)
treec5f4de10edc31a97307453ebb2d1144e1c7a6e0f
parentf04099841879fd9fdec2ff2f8b89109109fa1ee0 (diff)
downloadvdr-plugin-epgsearch-ceb158e1bd9df3cc0c6f9243856faac6f735ffb8.tar.gz
vdr-plugin-epgsearch-ceb158e1bd9df3cc0c6f9243856faac6f735ffb8.tar.bz2
Fix more lock sequences.
-rw-r--r--menu_main.c42
-rw-r--r--menu_searchresults.c5
-rw-r--r--menu_whatson.c35
-rw-r--r--menu_whatson.h11
4 files changed, 50 insertions, 43 deletions
diff --git a/menu_main.c b/menu_main.c
index 912affe..d392e20 100644
--- a/menu_main.c
+++ b/menu_main.c
@@ -73,11 +73,10 @@ cMenuSearchMain::cMenuSearchMain(void)
}
if ((EPGSearchConfig.StartMenu == 1 || forceMenu == 1) && forceMenu != 2)
- {
- LOCK_SCHEDULES_READ;
+ {
InWhatsOnMenu = true;
- AddSubMenu(new cMenuWhatsOnSearch(Schedules, cDevice::CurrentChannel()));
- }
+ AddSubMenu(new cMenuWhatsOnSearch(cDevice::CurrentChannel()));
+ }
if (forceMenu == 3)
ShowSummary();
}
@@ -119,6 +118,7 @@ void cMenuSearchMain::PrepareSchedule(const cChannel *Channel)
cMenuTemplate* ScheduleTemplate = cTemplFile::GetTemplateByName("MenuSchedule");
eventObjects.Clear();
+ LOCK_TIMERS_READ;
const cSchedule *Schedule;
{
LOCK_SCHEDULES_READ;
@@ -148,10 +148,10 @@ void cMenuSearchMain::PrepareSchedule(const cChannel *Channel)
struct tm *t_event = localtime_r(&EventDate, &tm_rEvent);
struct tm *t_lastevent = localtime_r(&lastEventDate, &tm_rLastEvent);
if (t_event->tm_mday != t_lastevent->tm_mday)
- Add(new cMenuMyScheduleSepItem(Event));
+ Add(new cMenuMyScheduleSepItem(NULL, Event));
lastEventDate = EventDate;
}
- Add(new cMenuMyScheduleItem(Event, NULL, showNow, ScheduleTemplate), Event == PresentEvent);
+ Add(new cMenuMyScheduleItem(Timers, Event, NULL, showNow, ScheduleTemplate), Event == PresentEvent);
eventObjects.Add(Event);
}
}
@@ -170,8 +170,9 @@ void cMenuSearchMain::PrepareSchedule(const cChannel *Channel)
bool cMenuSearchMain::Update(void)
{
bool result = false;
+ LOCK_TIMERS_READ;
for (cOsdItem *item = First(); item; item = Next(item)) {
- if (item->Selectable() && ((cMenuMyScheduleItem *)item)->Update())
+ if (item->Selectable() && ((cMenuMyScheduleItem *)item)->Update(Timers))
result = true;
}
return result;
@@ -436,10 +437,6 @@ eOSState cMenuSearchMain::ProcessKey(eKeys Key)
break;
case kGreen:
{
- LOCK_CHANNELS_READ;
- LOCK_SCHEDULES_READ;
- if (Schedules)
- {
if (HasSubMenu() && !InWhatsOnMenu && !InFavoritesMenu)
{
if (Count())
@@ -455,6 +452,7 @@ eOSState cMenuSearchMain::ProcessKey(eKeys Key)
cMenuMyScheduleItem* Item = (cMenuMyScheduleItem *)Get(Current());
if (Item && Item->event)
{
+ LOCK_CHANNELS_READ;
const cChannel *channel = Channels->GetByChannelID(Item->event->ChannelID(), true, true);
if (channel)
ChannelNr = channel->Number();
@@ -468,12 +466,16 @@ eOSState cMenuSearchMain::ProcessKey(eKeys Key)
else
{
InWhatsOnMenu = true;
- return AddSubMenu(new cMenuWhatsOnSearch(Schedules, ChannelNr));
+ return AddSubMenu(new cMenuWhatsOnSearch(ChannelNr));
}
}
else
{
- const cChannel *channel = Channels->GetByNumber(currentChannel-1,-1);
+ const cChannel *channel;
+ {
+ LOCK_CHANNELS_READ;
+ channel = Channels->GetByNumber(currentChannel-1,-1);
+ }
if (channel) {
PrepareSchedule(channel);
@@ -485,14 +487,9 @@ eOSState cMenuSearchMain::ProcessKey(eKeys Key)
SetHelpKeys(true);
return osContinue;
}
- }
}
case kYellow:
{
- LOCK_CHANNELS_READ;
- LOCK_SCHEDULES_READ;
- if (Schedules)
- {
if (HasSubMenu())
{
if (Count())
@@ -505,11 +502,15 @@ eOSState cMenuSearchMain::ProcessKey(eKeys Key)
{
cMenuWhatsOnSearch::currentShowMode = showNext;
InWhatsOnMenu = true;
- return AddSubMenu(new cMenuWhatsOnSearch(Schedules, cMenuWhatsOnSearch::CurrentChannel()));
+ return AddSubMenu(new cMenuWhatsOnSearch(cMenuWhatsOnSearch::CurrentChannel()));
}
else
{
- const cChannel *channel = Channels->GetByNumber(currentChannel+1,1);
+ const cChannel *channel;
+ {
+ LOCK_CHANNELS_READ;
+ channel = Channels->GetByNumber(currentChannel+1,1);
+ }
if (channel) {
PrepareSchedule(channel);
if (channel->Number() != cDevice::CurrentChannel()) {
@@ -520,7 +521,6 @@ eOSState cMenuSearchMain::ProcessKey(eKeys Key)
SetHelpKeys(true);
return osContinue;
}
- }
break;
}
case kBlue:
diff --git a/menu_searchresults.c b/menu_searchresults.c
index 5c2019b..99c11bf 100644
--- a/menu_searchresults.c
+++ b/menu_searchresults.c
@@ -345,8 +345,11 @@ eOSState cMenuSearchResults::ShowSummary()
const cEvent *ei = ((cMenuSearchResultsItem *)Get(Current()))->event;
if (ei)
{
+ const cChannel *channel;
+ {
LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(ei->ChannelID(), true, true);
+ channel = Channels->GetByChannelID(ei->ChannelID(), true, true);
+ }
if (channel)
return AddSubMenu(new cMenuEventSearch(ei, eventObjects));
}
diff --git a/menu_whatson.c b/menu_whatson.c
index 442c944..e84bb95 100644
--- a/menu_whatson.c
+++ b/menu_whatson.c
@@ -55,7 +55,7 @@ extern bool isUTF8;
int gl_InfoConflict = 0;
// --- cMenuMyScheduleItem ------------------------------------------------------
-cMenuMyScheduleItem::cMenuMyScheduleItem(const cEvent *Event, const cChannel *Channel, showMode Mode, cMenuTemplate* MenuTemplate)
+cMenuMyScheduleItem::cMenuMyScheduleItem(const cTimers *Timers, const cEvent *Event, const cChannel *Channel, showMode Mode, cMenuTemplate* MenuTemplate)
{
event = Event;
channel = Channel;
@@ -63,10 +63,10 @@ cMenuMyScheduleItem::cMenuMyScheduleItem(const cEvent *Event, const cChannel *Ch
timerMatch = tmNone;
inSwitchList = false;
menuTemplate = MenuTemplate;
- Update(true);
+ Update(Timers, true);
}
-bool cMenuMyScheduleItem::Update(bool Force)
+bool cMenuMyScheduleItem::Update(const cTimers* Timers, bool Force)
{
if (!menuTemplate)
return false;
@@ -81,7 +81,6 @@ bool cMenuMyScheduleItem::Update(bool Force)
bool OldInSwitchList = inSwitchList;
bool hasMatch = false;
const cTimer* timer = NULL;
- LOCK_TIMERS_READ;
if (event) timer = Timers->GetMatch(event, &timerMatch);
if (event) inSwitchList = (SwitchTimers.InSwitchList(event)!=NULL);
if (timer) hasMatch = true;
@@ -256,14 +255,14 @@ void cMenuMyScheduleItem::SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index,
}
// --- cMenuMyScheduleSepItem ------------------------------------------------------
-cMenuMyScheduleSepItem::cMenuMyScheduleSepItem(const cEvent *Event, const cChannel *Channel)
- : cMenuMyScheduleItem(Event, Channel, showNow, NULL)
+cMenuMyScheduleSepItem::cMenuMyScheduleSepItem(const cTimers *Timers, const cEvent *Event, const cChannel *Channel)
+ : cMenuMyScheduleItem(Timers, Event, Channel, showNow, NULL)
{
event = Event;
channel = Channel;
dummyEvent = NULL;
SetSelectable(false);
- Update(true);
+ Update(Timers, true);
}
cMenuMyScheduleSepItem::~cMenuMyScheduleSepItem()
@@ -272,7 +271,7 @@ cMenuMyScheduleSepItem::~cMenuMyScheduleSepItem()
delete dummyEvent;
}
-bool cMenuMyScheduleSepItem::Update(bool Force)
+bool cMenuMyScheduleSepItem::Update(const cTimers *Timers, bool Force)
{
if (channel)
SetText(cString::sprintf("%s\t %s %s", MENU_SEPARATOR_ITEMS, channel->Name(), MENU_SEPARATOR_ITEMS));
@@ -303,7 +302,7 @@ cList<cShowMode> cMenuWhatsOnSearch::showModes;
time_t cMenuWhatsOnSearch::seekTime = 0;
int cMenuWhatsOnSearch::shiftTime = 0;
-cMenuWhatsOnSearch::cMenuWhatsOnSearch(const cSchedules *Schedules, int CurrentChannelNr)
+cMenuWhatsOnSearch::cMenuWhatsOnSearch(int CurrentChannelNr)
:cOsdMenu("", GetTab(1), GetTab(2), GetTab(3), GetTab(4), GetTab(5))
{
if (currentShowMode == showNow)
@@ -315,7 +314,6 @@ cMenuWhatsOnSearch::cMenuWhatsOnSearch(const cSchedules *Schedules, int CurrentC
helpKeys = -1;
shiftTime = 0;
- schedules = Schedules;
CreateShowModes();
@@ -424,6 +422,7 @@ void cMenuWhatsOnSearch::LoadSchedules()
if (currentChannel > maxChannel)
maxChannel = 0;
+ LOCK_TIMERS_READ; // needed in MyScheduleItem
LOCK_CHANNELS_READ;
for (const cChannel *Channel = Channels->First(); Channel; Channel = Channels->Next(Channel))
{
@@ -433,7 +432,11 @@ void cMenuWhatsOnSearch::LoadSchedules()
if (EPGSearchConfig.showRadioChannels == 0 && ISRADIO(Channel))
continue;
- const cSchedule *Schedule = schedules->GetSchedule(Channel);
+ const cSchedule *Schedule;
+ {
+ LOCK_SCHEDULES_READ;
+ Schedule = Schedules->GetSchedule(Channel);
+ }
const cEvent *Event = NULL;
if (Schedule)
{
@@ -462,13 +465,13 @@ void cMenuWhatsOnSearch::LoadSchedules()
if (!EPGSearchConfig.showEmptyChannels && !Event)
continue;
- Add(new cMenuMyScheduleItem(Event, Channel, currentShowMode, currentTemplate), Channel->Number() == currentChannel);
+ Add(new cMenuMyScheduleItem(Timers, Event, Channel, currentShowMode, currentTemplate), Channel->Number() == currentChannel);
if (Event) eventObjects.Add(Event);
}
else
{
if (EPGSearchConfig.showChannelGroups && strlen(Channel->Name()))
- Add(new cMenuMyScheduleSepItem(NULL, Channel));
+ Add(new cMenuMyScheduleSepItem(NULL, NULL, Channel));
}
}
}
@@ -652,8 +655,9 @@ eOSState cMenuWhatsOnSearch::Record(void)
bool cMenuWhatsOnSearch::Update(void)
{
bool result = false;
+ LOCK_TIMERS_READ;
for (cOsdItem *item = First(); item; item = Next(item)) {
- if (item->Selectable() && ((cMenuMyScheduleItem *)item)->Update())
+ if (item->Selectable() && ((cMenuMyScheduleItem *)item)->Update(Timers))
result = true;
}
return result;
@@ -838,7 +842,8 @@ eOSState cMenuWhatsOnSearch::ProcessKey(eKeys Key)
cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current());
if (mi && mi->Selectable() && mi->channel)
{
- const cSchedule *Schedule = schedules->GetSchedule(mi->channel);
+ LOCK_SCHEDULES_READ;
+ const cSchedule *Schedule = Schedules->GetSchedule(mi->channel);
if (Schedule)
{
time_t now = time(NULL);
diff --git a/menu_whatson.h b/menu_whatson.h
index 4c65bd6..65a2b73 100644
--- a/menu_whatson.h
+++ b/menu_whatson.h
@@ -39,8 +39,8 @@ public:
bool inSwitchList;
cMenuTemplate* menuTemplate;
- cMenuMyScheduleItem(const cEvent *Event, const cChannel *Channel = NULL, showMode ShowMode = showNow, cMenuTemplate* menuTemplate = NULL);
- virtual bool Update(bool Force = false);
+ cMenuMyScheduleItem(const cTimers *Timers, const cEvent *Event, const cChannel *Channel = NULL, showMode ShowMode = showNow, cMenuTemplate* menuTemplate = NULL);
+ virtual bool Update(const cTimers *Timers, bool Force = false);
virtual void SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable);
};
@@ -52,9 +52,9 @@ class cMenuMyScheduleSepItem : public cMenuMyScheduleItem {
// if VDR had a SetItemSeparator function for this
public:
- cMenuMyScheduleSepItem(const cEvent *Event, const cChannel *Channel = NULL);
+ cMenuMyScheduleSepItem(const cTimers *Timers = NULL, const cEvent *Event = NULL, const cChannel *Channel = NULL);
~cMenuMyScheduleSepItem();
- virtual bool Update(bool Force = false);
+ virtual bool Update(const cTimers *Timers = NULL,bool Force = false);
virtual void SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable);
};
@@ -62,7 +62,6 @@ public:
class cMenuWhatsOnSearch : public cOsdMenu {
private:
int helpKeys;
- const cSchedules* schedules;
eOSState Record(void);
eOSState ExtendedSearch(void);
static int currentChannel;
@@ -75,7 +74,7 @@ private:
static time_t seekTime;
time_t GetTimeT(int iTime);
static showMode GetNextMode();
- cMenuWhatsOnSearch(const cSchedules *Schedules, int CurrentChannelNr);
+ cMenuWhatsOnSearch(int CurrentChannelNr);
~cMenuWhatsOnSearch();
void LoadSchedules();
static int CurrentChannel(void) { return currentChannel; }