summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Eskola <timo@tolleri.net>2018-09-06 07:48:02 (GMT)
committerTimo Eskola <timo@tolleri.net>2018-09-06 07:48:02 (GMT)
commitcb2d73192b0c50f7b8f832f95e03fe9da430dec5 (patch)
tree7b9857c55c7b955c1887d0a90d4e68dee62b5d1e
parent7378e32aa471bb3861d39a6eaba57574cc39612a (diff)
parent169e1700feef224417172ee48354fdd7c0f8374a (diff)
downloadvdr-plugin-duplicates-cb2d73192b0c50f7b8f832f95e03fe9da430dec5.tar.gz
vdr-plugin-duplicates-cb2d73192b0c50f7b8f832f95e03fe9da430dec5.tar.bz2
Merge branch 'master' into vdr2.4.0
-rw-r--r--HISTORY3
-rw-r--r--menu.c18
-rw-r--r--recording.c42
3 files changed, 38 insertions, 25 deletions
diff --git a/HISTORY b/HISTORY
index 9e18b5e..12facb2 100644
--- a/HISTORY
+++ b/HISTORY
@@ -5,7 +5,7 @@ VDR Plugin 'duplicates' Revision History
- Dropped support for VDR 2.2.0.
- Added scanner thread for duplicates.
-2018-09-05: Version 0.2.2
+2018-09-06: Version 0.2.2
- Updated kNone handling in main menu.
- Improved duplicate recording copy constructor.
@@ -13,6 +13,7 @@ VDR Plugin 'duplicates' Revision History
- Simplified toggle hidden.
- Fixed recordings locking sequence.
- Check for vanished recorgins in info menu.
+- Added checks for empty lists.
2018-08-30: Version 0.2.1
diff --git a/menu.c b/menu.c
index a9f27eb..a5ec3d3 100644
--- a/menu.c
+++ b/menu.c
@@ -176,12 +176,16 @@ void cMenuDuplicates::Set(bool Refresh) {
CurrentRecording = cReplayControl::LastReplayed();
Clear();
for (cDuplicateRecording *Duplicates = DuplicateRecordings.First(); Duplicates; Duplicates = DuplicateRecordings.Next(Duplicates)) {
- Add(SeparatorItem(Duplicates->Text().c_str()));
- for (cDuplicateRecording *Duplicate = Duplicates->Duplicates()->First(); Duplicate; Duplicate = Duplicates->Duplicates()->Next(Duplicate)) {
- cMenuDuplicateItem *Item = new cMenuDuplicateItem(Duplicate);
- Add(Item);
- if (CurrentRecording && strcmp(CurrentRecording, Item->FileName()) == 0)
- SetCurrent(Item);
+ if (Duplicates) {
+ Add(SeparatorItem(Duplicates->Text().c_str()));
+ for (cDuplicateRecording *Duplicate = Duplicates->Duplicates()->First(); Duplicate; Duplicate = Duplicates->Duplicates()->Next(Duplicate)) {
+ if (Duplicate) {
+ cMenuDuplicateItem *Item = new cMenuDuplicateItem(Duplicate);
+ Add(Item);
+ if (CurrentRecording && strcmp(CurrentRecording, Item->FileName()) == 0)
+ SetCurrent(Item);
+ }
+ }
}
}
duplicateRecordingsStateKey.Remove();
@@ -189,7 +193,7 @@ void cMenuDuplicates::Set(bool Refresh) {
Add(SeparatorItem(cString::sprintf(tr("%d duplicate recordings"), 0)));
if (Refresh) {
SetCurrentIndex(currentIndex);
- Display();
+ Display();
}
}
}
diff --git a/recording.c b/recording.c
index 666f499..c3a6ae9 100644
--- a/recording.c
+++ b/recording.c
@@ -56,7 +56,8 @@ cDuplicateRecording::cDuplicateRecording(const cDuplicateRecording &DuplicateRec
if (DuplicateRecording.duplicates != NULL) {
duplicates = new cList<cDuplicateRecording>;
for (const cDuplicateRecording *duplicate = DuplicateRecording.duplicates->First(); duplicate; duplicate = DuplicateRecording.duplicates->Next(duplicate)) {
- duplicates->Add(new cDuplicateRecording(*duplicate));
+ if (duplicate)
+ duplicates->Add(new cDuplicateRecording(*duplicate));
}
} else
duplicates = NULL;
@@ -94,16 +95,20 @@ bool cDuplicateRecordings::RemoveDeleted(void) {
dsyslog("duplicates: Removing deleted recordings.");
int removed = 0;
for (cDuplicateRecording *duplicates = First(); duplicates; duplicates = Next(duplicates)) {
- for (cDuplicateRecording *duplicate = duplicates->Duplicates()->First(); duplicate; duplicate = duplicates->Duplicates()->Next(duplicate)) {
- LOCK_RECORDINGS_READ
- const cRecording *recording = Recordings->GetByName(duplicate->FileName().c_str());
- if (!recording || !dc.hidden && duplicate->Visibility().Read() == HIDDEN) {
- duplicates->Duplicates()->Del(duplicate);
- removed++;
+ if (duplicates) {
+ for (cDuplicateRecording *duplicate = duplicates->Duplicates()->First(); duplicate; duplicate = duplicates->Duplicates()->Next(duplicate)) {
+ if (duplicate) {
+ LOCK_RECORDINGS_READ
+ const cRecording *recording = Recordings->GetByName(duplicate->FileName().c_str());
+ if (!recording || !dc.hidden && duplicate->Visibility().Read() == HIDDEN) {
+ duplicates->Duplicates()->Del(duplicate);
+ removed++;
+ }
+ }
}
+ if (duplicates->Duplicates()->Count() < 2)
+ Del(duplicates);
}
- if (duplicates->Duplicates()->Count() < 2)
- Del(duplicates);
}
dsyslog("duplicates: Removed %d deleted recordings.", removed);
return removed > 0;
@@ -154,11 +159,13 @@ void cDuplicateRecordingScannerThread::Scan(void) {
cRecordings *Recordings = cRecordings::GetRecordingsWrite(recordingsStateKey); // write access is necessary for sorting!
Recordings->Sort();
for (const cRecording *recording = Recordings->First(); recording; recording = Recordings->Next(recording)) {
- cDuplicateRecording *Item = new cDuplicateRecording(recording);
- if (Item->HasDescription())
- recordings.Add(Item);
- else if (dc.hidden || Item->Visibility().Read() != HIDDEN)
- descriptionless->Duplicates()->Add(Item);
+ if (recording) {
+ cDuplicateRecording *Item = new cDuplicateRecording(recording);
+ if (Item->HasDescription())
+ recordings.Add(Item);
+ else if (dc.hidden || Item->Visibility().Read() != HIDDEN)
+ descriptionless->Duplicates()->Add(Item);
+ }
}
recordingsStateKey.Remove(false); // sorting doesn't count as a real modification
cList<cDuplicateRecording> duplicates;
@@ -169,12 +176,12 @@ void cDuplicateRecordingScannerThread::Scan(void) {
}
if (cIoThrottle::Engaged())
cCondWait::SleepMs(100);
- if (!recording->Checked()) {
+ if (recording &&!recording->Checked()) {
recording->SetChecked();
cDuplicateRecording *duplicate = new cDuplicateRecording();
duplicate->Duplicates()->Add(new cDuplicateRecording(*recording));
for (cDuplicateRecording *compare = recordings.First(); compare; compare = recordings.Next(compare)) {
- if (!compare->Checked()) {
+ if (compare && !compare->Checked()) {
if (recording->IsDuplicate(compare)) {
duplicate->Duplicates()->Add(new cDuplicateRecording(*compare));
compare->SetChecked();
@@ -198,7 +205,8 @@ void cDuplicateRecordingScannerThread::Scan(void) {
DuplicateRecordings.Lock(duplicateRecordingsStateKey, true);
DuplicateRecordings.Clear();
for (cDuplicateRecording *duplicate = duplicates.First(); duplicate; duplicate = duplicates.Next(duplicate)) {
- DuplicateRecordings.Add(new cDuplicateRecording(*duplicate));
+ if (duplicate)
+ DuplicateRecordings.Add(new cDuplicateRecording(*duplicate));
}
duplicateRecordingsStateKey.Remove();
gettimeofday(&stopTime, NULL);