diff --git a/recmanager.c b/recmanager.c index 1c56c97..58e616b 100644 --- a/recmanager.c +++ b/recmanager.c @@ -130,7 +130,7 @@ cTimer *cRecManager::createLocalTimer(const cEvent *event, std::string path) { isyslog("timer %s added (active)", *timer->ToDescr()); #endif } - return timer; + return timers->GetTimer(timer); } cTimer *cRecManager::createRemoteTimer(const cEvent *event, std::string path) { diff --git a/recmenu.c b/recmenu.c index 832e362..a1e6eb6 100644 --- a/recmenu.c +++ b/recmenu.c @@ -589,10 +589,14 @@ void cRecMenu::UpdateActiveMenuItem(void) { void cRecMenu::DrawScrollBar(void) { + if (!pixmapScrollBar) + return; pixmapScrollBar->Fill(theme.Color(clrBorder)); pixmapScrollBar->DrawRectangle(cRect(2,2,pixmapScrollBar->ViewPort().Width()-4, pixmapScrollBar->ViewPort().Height() - 4), theme.Color(clrBackground)); int totalNumItems = GetTotalNumMenuItems(); + if (!totalNumItems) + return; if (imgScrollBar == NULL) { int scrollBarImgHeight = (pixmapScrollBar->ViewPort().Height() - 8) * numItems / totalNumItems; imgScrollBar = createScrollbar(pixmapScrollBar->ViewPort().Width()-8, scrollBarImgHeight, theme.Color(clrHighlight), theme.Color(clrHighlightBlending)); diff --git a/recmenuitem.c b/recmenuitem.c index b8fca6d..e8edf79 100644 --- a/recmenuitem.c +++ b/recmenuitem.c @@ -1548,6 +1548,7 @@ cRecMenuItemTimer::cRecMenuItemTimer(const cTimer *timer, this->overlapStop = overlapStop; this->active = active; height = 3 * font->Height(); + pixmapStatus = NULL; pixmapIcons = NULL; } @@ -1585,6 +1586,8 @@ void cRecMenuItemTimer::Show(void) { } void cRecMenuItemTimer::Draw(void) { + if (!timer) + return; const cChannel *channel = timer->Channel(); int channelTransponder = 0; cString channelName = ""; @@ -1740,8 +1743,13 @@ cRecMenuItemTimerConflictHeader::~cRecMenuItemTimerConflictHeader(void) { } void cRecMenuItemTimerConflictHeader::SetPixmaps(void) { - pixmap = osdManager.requestPixmap(4, cRect(x, y, width, height)); - pixmapStatus = osdManager.requestPixmap(5, cRect(x, y, width, height)); + if (!pixmap) { + pixmap = osdManager.requestPixmap(4, cRect(x, y, width, height)); + pixmapStatus = osdManager.requestPixmap(5, cRect(x, y, width, height)); + } else { + pixmap->SetViewPort(cRect(x, y, width, height)); + pixmapStatus->SetViewPort(cRect(x, y, width, height)); + } pixmapStatus->Fill(clrTransparent); } diff --git a/recmenus.c b/recmenus.c index 80213cc..243a72c 100644 --- a/recmenus.c +++ b/recmenus.c @@ -194,8 +194,9 @@ cRecMenuAskDeleteTimer::cRecMenuAskDeleteTimer(const cEvent *event) { // --- cRecMenuTimerConflicts --------------------------------------------------------- cRecMenuTimerConflicts::cRecMenuTimerConflicts(cTVGuideTimerConflicts *conflicts) { - int numConflicts = conflicts->NumConflicts(); - + SetWidthPercent(50); + + int numConflicts = (conflicts) ? conflicts->NumConflicts() : 0; cString text; if (numConflicts == 1) { text = cString::sprintf("%s %s %s", tr("One"), tr("Timer Conflict"), tr("detected")); @@ -233,16 +234,18 @@ int cRecMenuTimerConflicts::GetTimerConflict(void) { cRecMenuTimerConflict::cRecMenuTimerConflict(cTVGuideTimerConflict *conflict) { SetWidthPercent(95); this->conflict = conflict; - SetHeader(new cRecMenuItemTimerConflictHeader(conflict->timeStart, - conflict->timeStop, - conflict->overlapStart, + totalNumMenuItems = (int)conflict->timerIDs.size(); + + SetHeader(new cRecMenuItemTimerConflictHeader(conflict->timeStart, + conflict->timeStop, + conflict->overlapStart, conflict->overlapStop)); SetFooter(new cRecMenuItemButton(tr("Ignore Conflict"), rmsIgnoreTimerConflict, false, true)); int i=0; for(std::vector::iterator it = conflict->timerIDs.begin(); it != conflict->timerIDs.end(); it++) { #if VDRVERSNUM >= 20301 LOCK_TIMERS_READ; - const cTimer *timer = Timers->Get(*it); + const cTimer *timer = Timers->GetById(*it + 1); #else const cTimer *timer = Timers.Get(*it); #endif @@ -268,7 +271,7 @@ cRecMenuTimerConflict::cRecMenuTimerConflict(cTVGuideTimerConflict *conflict) { } cRecMenuItem *cRecMenuTimerConflict::GetMenuItem(int number) { - if ((number >= 0) && (number < (int)conflict->timerIDs.size())) { + if ((number >= 0) && (number < totalNumMenuItems)) { #if VDRVERSNUM >= 20301 LOCK_TIMERS_READ; const cTimer *timer = Timers->Get(conflict->timerIDs[number]); @@ -290,8 +293,8 @@ cRecMenuItem *cRecMenuTimerConflict::GetMenuItem(int number) { return NULL; } -int cRecMenuTimerConflict::GetTotalNumMenuItems(void) { - return conflict->timerIDs.size(); +int cRecMenuTimerConflict::GetTotalNumMenuItems(void) { + return totalNumMenuItems; } int cRecMenuTimerConflict::GetTimerConflictIndex(void) { diff --git a/recmenus.h b/recmenus.h index d8401e8..4c9b726 100644 --- a/recmenus.h +++ b/recmenus.h @@ -77,11 +77,12 @@ public: class cRecMenuTimerConflict: public cRecMenu { private: cTVGuideTimerConflict *conflict; + int totalNumMenuItems; public: cRecMenuTimerConflict(cTVGuideTimerConflict *conflict); + virtual ~cRecMenuTimerConflict(void) {}; cRecMenuItem *GetMenuItem(int number); int GetTotalNumMenuItems(void); - virtual ~cRecMenuTimerConflict(void) {}; int GetTimerConflictIndex(void); }; diff --git a/recmenuview.c b/recmenuview.c index f8a5493..74e6f2b 100644 --- a/recmenuview.c +++ b/recmenuview.c @@ -93,7 +93,6 @@ void cRecMenuView::DisplaySearchTimerList(void) { } bool cRecMenuView::DisplayTimerConflict(const cTimer *timer) { - int timerID = 0; #if VDRVERSNUM >= 20301 LOCK_TIMERS_READ; for (const cTimer *t = Timers->First(); t; t = Timers->Next(t)) { @@ -101,8 +100,7 @@ bool cRecMenuView::DisplayTimerConflict(const cTimer *timer) { for (const cTimer *t = Timers.First(); t; t = Timers.Next(t)) { #endif if (t == timer) - return DisplayTimerConflict(timerID); - timerID++; + return DisplayTimerConflict(timer->Id() - 1); } return false; } @@ -229,10 +227,10 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) { if (cRecMenuTimerConflict *menu = dynamic_cast(activeMenu)) { timerIndex = menu->GetTimerConflictIndex(); } else break; - int timerID = timerConflicts->GetCurrentConflictTimerID(timerIndex); + int timerID = timerConflicts->GetCurrentConflictTimerID(timerIndex) + 1; #if VDRVERSNUM >= 20301 LOCK_TIMERS_READ; - const cTimer *t = Timers->Get(timerID); + const cTimer *t = Timers->GetById(timerID); #else const cTimer *t = Timers.Get(timerID); #endif @@ -250,7 +248,7 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) { if (cRecMenuTimerConflict *menu = dynamic_cast(activeMenu)) { timerIndex = menu->GetTimerConflictIndex(); } else break; - int timerID = timerConflicts->GetCurrentConflictTimerID(timerIndex); + int timerID = timerConflicts->GetCurrentConflictTimerID(timerIndex) + 1; const cTimers* timers; #if VDRVERSNUM >= 20301 { @@ -260,10 +258,11 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) { #else timers = &Timers; #endif - recManager->DeleteTimer(timers->Get(timerID)->Event()); + const cEvent *event = timers->GetById(timerID)->Event(); + recManager->DeleteTimer(event); // (timerID); delete activeMenu; if (!DisplayTimerConflict(timerID)) { - activeMenu = new cRecMenuConfirmTimer(timers->Get(timerID)->Event()); + activeMenu = new cRecMenuConfirmDeleteTimer(event); activeMenu->Display(); } break; } @@ -274,10 +273,10 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) { if (cRecMenuTimerConflict *menu = dynamic_cast(activeMenu)) { timerIndex = menu->GetTimerConflictIndex(); } else break; - int timerID = timerConflicts->GetCurrentConflictTimerID(timerIndex); + int timerID = timerConflicts->GetCurrentConflictTimerID(timerIndex) + 1; #if VDRVERSNUM >= 20301 LOCK_TIMERS_READ; - const cTimer *timer = Timers->Get(timerID); + const cTimer *timer = Timers->GetById(timerID); #else const cTimer *timer = Timers.Get(timerID); #endif @@ -660,10 +659,10 @@ eOSState cRecMenuView::StateMachine(eRecMenuState nextState) { if (cRecMenuTimerConflict *menu = dynamic_cast(activeMenu)) { timerConflict = menu->GetTimerConflictIndex(); } else break; - int timerID = timerConflicts->GetCurrentConflictTimerID(timerConflict); + int timerID = timerConflicts->GetCurrentConflictTimerID(timerConflict) + 1; #if VDRVERSNUM >= 20301 LOCK_TIMERS_READ; - const cTimer *timer = Timers->Get(timerID); + const cTimer *timer = Timers->GetById(timerID); #else cTimer *timer = Timers.Get(timerID); #endif diff --git a/timerconflict.c b/timerconflict.c index 1920a9c..2aaef7a 100644 --- a/timerconflict.c +++ b/timerconflict.c @@ -16,12 +16,11 @@ cTVGuideTimerConflict::cTVGuideTimerConflict(void) { } cTVGuideTimerConflict::~cTVGuideTimerConflict(void) { - } bool cTVGuideTimerConflict::timerInvolved(int involvedID) { int numConflicts = timerIDs.size(); - for (int i=0; iGet(conflicts[i]->timerIDs[j]); + const cTimer *timer = timers->GetById(conflicts[i]->timerIDs[j] + 1); if (timer) { if (!unionSet) { unionSet = new cTimeInterval(timer->StartTime(), timer->StopTime()); @@ -109,7 +107,7 @@ void cTVGuideTimerConflicts::CalculateConflicts(void) { cTimeInterval *intersect = NULL; for (int j=0; j < numTimers; j++) { - const cTimer *timer = timers->Get(conflicts[i]->timerIDs[j]); + const cTimer *timer = timers->GetById(conflicts[i]->timerIDs[j] + 1); if (timer) { if (!intersect) { intersect = new cTimeInterval(timer->StartTime(), timer->StopTime()); @@ -152,7 +150,7 @@ int cTVGuideTimerConflicts::GetCurrentConflictTimerID(int timerIndex) { int cTVGuideTimerConflicts::GetCorrespondingConflict(int timerID) { int conflictIndex = -1; if (numConflicts > 0) { - for (int i=0; itimerInvolved(timerID)) { conflictIndex = i; break; @@ -172,7 +170,7 @@ cTVGuideTimerConflict *cTVGuideTimerConflicts::GetConflict(int conflictIndex) { std::vector cTVGuideTimerConflicts::GetConflictsBetween(time_t start, time_t stop) { std::vector conflictsFound; - for (int i=0; i < numConflicts; i++) { + for (int i = 0; i < numConflicts; i++) { if ((conflicts[i]->timeStart > start) && (conflicts[i]->timeStart < stop)|| (conflicts[i]->timeStop > start) && (conflicts[i]->timeStop < stop)) conflictsFound.push_back(conflicts[i]);