summaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2013-01-16 16:08:20 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2013-01-16 16:08:20 +0100
commit7a3f809f5c421db13df2c34e70d2fb4eb98ddb32 (patch)
treed8030ad1396203dd763c8c9ade06ae883fd1a7d2 /menu.c
parenta9099cb4d30d8ecf4acb9a4cf31f3b818599c62e (diff)
downloadvdr-7a3f809f5c421db13df2c34e70d2fb4eb98ddb32.tar.gz
vdr-7a3f809f5c421db13df2c34e70d2fb4eb98ddb32.tar.bz2
Fixed multiple occurrences of the same directory in the recordings list in case there are directories that only differ in non-alphanumeric characters
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/menu.c b/menu.c
index 6c278b55..b42aa4da 100644
--- a/menu.c
+++ b/menu.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: menu.c 2.72 2012/12/21 11:11:14 kls Exp $
+ * $Id: menu.c 2.73 2013/01/16 15:58:58 kls Exp $
*/
#include "menu.h"
@@ -2273,7 +2273,6 @@ void cMenuRecordings::Set(bool Refresh)
{
const char *CurrentRecording = cReplayControl::LastReplayed();
cMenuRecordingItem *LastItem = NULL;
- char *LastItemText = NULL;
cThreadLock RecordingsLock(&Recordings);
if (Refresh) {
if (cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current()))
@@ -2285,23 +2284,32 @@ void cMenuRecordings::Set(bool Refresh)
for (cRecording *recording = Recordings.First(); recording; recording = Recordings.Next(recording)) {
if (!base || (strstr(recording->Name(), base) == recording->Name() && recording->Name()[strlen(base)] == FOLDERDELIMCHAR)) {
cMenuRecordingItem *Item = new cMenuRecordingItem(recording, level);
- if (*Item->Text() && (!Item->IsDirectory() || (!LastItem || !LastItem->IsDirectory() || strcmp(Item->Text(), LastItemText) != 0))) {
+ cMenuRecordingItem *LastDir = NULL;
+ if (Item->IsDirectory()) {
+ // Sorting may ignore non-alphanumeric characters, so we need to explicitly handle directories in case they only differ in such characters:
+ for (cMenuRecordingItem *p = LastItem; p; p = dynamic_cast<cMenuRecordingItem *>(p->Prev())) {
+ if (p->Name() && strcmp(p->Name(), Item->Name()) == 0) {
+ LastDir = p;
+ break;
+ }
+ }
+ }
+ if (*Item->Text() && !LastDir) {
Add(Item);
LastItem = Item;
- free(LastItemText);
- LastItemText = strdup(LastItem->Text()); // must use a copy because of the counters!
+ if (Item->IsDirectory())
+ LastDir = Item;
}
else
delete Item;
if (LastItem) {
if (CurrentRecording && strcmp(CurrentRecording, recording->FileName()) == 0)
SetCurrent(LastItem);
- if (LastItem->IsDirectory())
- LastItem->IncrementCounter(recording->IsNew());
}
+ if (LastDir)
+ LastDir->IncrementCounter(recording->IsNew());
}
}
- free(LastItemText);
if (Refresh)
Display();
}