From 17300da7b229b3178f9f947d35eceae96846cbdd Mon Sep 17 00:00:00 2001
From: Thomas Keil <tkeil (at) datacrystal (dot) de>
Date: Thu, 4 Jan 2007 14:48:29 +0000
Subject: added Channel-Locks

---
 pages/whats_on_next.ecpp | 25 ++++++++++++++-----------
 pages/whats_on_now.ecpp  | 25 ++++++++++++++-----------
 2 files changed, 28 insertions(+), 22 deletions(-)

(limited to 'pages')

diff --git a/pages/whats_on_next.ecpp b/pages/whats_on_next.ecpp
index 22df5df..6145864 100644
--- a/pages/whats_on_next.ecpp
+++ b/pages/whats_on_next.ecpp
@@ -35,21 +35,24 @@ const cSchedules* Schedules = cSchedules::Schedules(schedulesLock);
 			</div>
 
 <{
-	for (cChannel *Channel = Channels.First(); Channel && Channel->Number() <= LiveSetup().GetLastChannel(); Channel = Channels.Next(Channel)) {
-		if (!Channel->GroupSep()) {
-			const cSchedule *Schedule = Schedules->GetSchedule(Channel);
-			if (Schedule) {
-				const cEvent *Event = Schedule->GetFollowingEvent();
-					if (Event) {
-						std::string title(Event->Title() ? Event->Title() : "");
-						std::string short_description(Event->ShortText() ? Event->ShortText() : "");
-						std::string description(Event->Description() ? Event->Description() : "");
-						std::string start(Event->StartTime() ? FormatDateTime(tr("%I:%M %p"), Event->StartTime()) : "");
-						std::string end(Event->EndTime() ? FormatDateTime(tr("%I:%M %p"), Event->EndTime()) : "");
+	ReadLock channelsLock( Channels );
+	if (channelsLock) {
+		for (cChannel *Channel = Channels.First(); Channel && Channel->Number() <= LiveSetup().GetLastChannel(); Channel = Channels.Next(Channel)) {
+			if (!Channel->GroupSep()) {
+				const cSchedule *Schedule = Schedules->GetSchedule(Channel);
+				if (Schedule) {
+					const cEvent *Event = Schedule->GetFollowingEvent();
+						if (Event) {
+							std::string title(Event->Title() ? Event->Title() : "");
+							std::string short_description(Event->ShortText() ? Event->ShortText() : "");
+							std::string description(Event->Description() ? Event->Description() : "");
+							std::string start(Event->StartTime() ? FormatDateTime(tr("%I:%M %p"), Event->StartTime()) : "");
+							std::string end(Event->EndTime() ? FormatDateTime(tr("%I:%M %p"), Event->EndTime()) : "");
 }>
 <& event_widget title=(title) short_description=(short_description) description=(description) channel_name=(Channel->Name()) start=(start) end=(end)>
 <{
 					}
+				}
 			}
 		}
 	}
diff --git a/pages/whats_on_now.ecpp b/pages/whats_on_now.ecpp
index e0a2ba1..a79be7d 100644
--- a/pages/whats_on_now.ecpp
+++ b/pages/whats_on_now.ecpp
@@ -35,21 +35,24 @@ const cSchedules* Schedules = cSchedules::Schedules(schedulesLock);
 			</div>
 
 <{
-	for (cChannel *Channel = Channels.First(); Channel && Channel->Number() <= LiveSetup().GetLastChannel(); Channel = Channels.Next(Channel)) {
-		if (!Channel->GroupSep()) {
-			const cSchedule *Schedule = Schedules->GetSchedule(Channel);
-			if (Schedule) {
-				const cEvent *Event = Schedule->GetPresentEvent();
-					if (Event) {
-						std::string title(Event->Title() ? Event->Title() : "");
-						std::string short_description(Event->ShortText() ? Event->ShortText() : "");
-						std::string description(Event->Description() ? Event->Description() : "");
-						std::string start(Event->StartTime() ? FormatDateTime(tr("%I:%M %p"), Event->StartTime()) : "");
-						std::string end(Event->EndTime() ? FormatDateTime(tr("%I:%M %p"), Event->EndTime()) : "");
+	ReadLock channelsLock( Channels );
+	if (channelsLock) {
+		for (cChannel *Channel = Channels.First(); Channel && Channel->Number() <= LiveSetup().GetLastChannel(); Channel = Channels.Next(Channel)) {
+			if (!Channel->GroupSep()) {
+				const cSchedule *Schedule = Schedules->GetSchedule(Channel);
+				if (Schedule) {
+					const cEvent *Event = Schedule->GetPresentEvent();
+						if (Event) {
+							std::string title(Event->Title() ? Event->Title() : "");
+							std::string short_description(Event->ShortText() ? Event->ShortText() : "");
+							std::string description(Event->Description() ? Event->Description() : "");
+							std::string start(Event->StartTime() ? FormatDateTime(tr("%I:%M %p"), Event->StartTime()) : "");
+							std::string end(Event->EndTime() ? FormatDateTime(tr("%I:%M %p"), Event->EndTime()) : "");
 }>
 <& event_widget title=(title) short_description=(short_description) description=(description) channel_name=(Channel->Name()) start=(start) end=(end)>
 <{
 					}
+				}
 			}
 		}
 	}
-- 
cgit v1.2.3