mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Fixed a crash when cancelling a newly created timer
This commit is contained in:
parent
3208f4eddd
commit
2390d7b1fd
@ -712,3 +712,6 @@ Karim Afifi <karim.afifi@free.fr>
|
|||||||
|
|
||||||
Jon Burgess <mplayer@jburgess.uklinux.net>
|
Jon Burgess <mplayer@jburgess.uklinux.net>
|
||||||
for pointing out a problem with NPTL ("Native Posix Thread Library")
|
for pointing out a problem with NPTL ("Native Posix Thread Library")
|
||||||
|
|
||||||
|
Thomas Schmidt <thomas.schmidt@in.stud.tu-ilmenau.de>
|
||||||
|
for reporting a crash when cancelling a newly created timer
|
||||||
|
2
HISTORY
2
HISTORY
@ -2241,3 +2241,5 @@ Video Disk Recorder Revision History
|
|||||||
Gruber for reporting this one).
|
Gruber for reporting this one).
|
||||||
- Fixed editing channels ('timers.conf' was not written after a channel has
|
- Fixed editing channels ('timers.conf' was not written after a channel has
|
||||||
been modified, which could result in errors upon the next start of VDR).
|
been modified, which could result in errors upon the next start of VDR).
|
||||||
|
- Fixed a crash when cancelling a newly created timer (thanks to Thomas Schmidt
|
||||||
|
for reporting this one).
|
||||||
|
72
menu.c
72
menu.c
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: menu.c 1.254 2003/06/06 12:56:05 kls Exp $
|
* $Id: menu.c 1.255 2003/06/06 14:59:47 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
@ -835,21 +835,21 @@ private:
|
|||||||
cTimer *timer;
|
cTimer *timer;
|
||||||
cTimer data;
|
cTimer data;
|
||||||
int channel;
|
int channel;
|
||||||
bool deleteIfCancelled;
|
bool addIfConfirmed;
|
||||||
cMenuEditDateItem *firstday;
|
cMenuEditDateItem *firstday;
|
||||||
void SetFirstDayItem(void);
|
void SetFirstDayItem(void);
|
||||||
public:
|
public:
|
||||||
cMenuEditTimer(int Index, bool New = false);
|
cMenuEditTimer(cTimer *Timer, bool New = false);
|
||||||
virtual ~cMenuEditTimer();
|
virtual ~cMenuEditTimer();
|
||||||
virtual eOSState ProcessKey(eKeys Key);
|
virtual eOSState ProcessKey(eKeys Key);
|
||||||
};
|
};
|
||||||
|
|
||||||
cMenuEditTimer::cMenuEditTimer(int Index, bool New)
|
cMenuEditTimer::cMenuEditTimer(cTimer *Timer, bool New)
|
||||||
:cOsdMenu(tr("Edit timer"), 12)
|
:cOsdMenu(tr("Edit timer"), 12)
|
||||||
{
|
{
|
||||||
firstday = NULL;
|
firstday = NULL;
|
||||||
timer = Timers.Get(Index);
|
timer = Timer;
|
||||||
deleteIfCancelled = New;
|
addIfConfirmed = New;
|
||||||
if (timer) {
|
if (timer) {
|
||||||
data = *timer;
|
data = *timer;
|
||||||
if (New)
|
if (New)
|
||||||
@ -870,12 +870,8 @@ cMenuEditTimer::cMenuEditTimer(int Index, bool New)
|
|||||||
|
|
||||||
cMenuEditTimer::~cMenuEditTimer()
|
cMenuEditTimer::~cMenuEditTimer()
|
||||||
{
|
{
|
||||||
if (timer && deleteIfCancelled) {
|
if (timer && addIfConfirmed)
|
||||||
int Index = timer->Index();
|
delete timer; // apparently it wasn't confirmed
|
||||||
Timers.Del(timer);
|
|
||||||
Timers.Save();
|
|
||||||
isyslog("timer %d deleted", Index + 1);
|
|
||||||
}
|
|
||||||
Timers.DecBeingEdited();
|
Timers.DecBeingEdited();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -909,14 +905,18 @@ eOSState cMenuEditTimer::ProcessKey(eKeys Key)
|
|||||||
}
|
}
|
||||||
if (!*data.file)
|
if (!*data.file)
|
||||||
strcpy(data.file, data.Channel()->Name());
|
strcpy(data.file, data.Channel()->Name());
|
||||||
if (timer && memcmp(timer, &data, sizeof(data)) != 0) {
|
if (timer) {
|
||||||
*timer = data;
|
if (memcmp(timer, &data, sizeof(data)) != 0) {
|
||||||
if (timer->active)
|
*timer = data;
|
||||||
timer->active = 1; // allows external programs to mark active timers with values > 1 and recognize if the user has modified them
|
if (timer->active)
|
||||||
|
timer->active = 1; // allows external programs to mark active timers with values > 1 and recognize if the user has modified them
|
||||||
|
}
|
||||||
|
if (addIfConfirmed)
|
||||||
|
Timers.Add(timer);
|
||||||
Timers.Save();
|
Timers.Save();
|
||||||
isyslog("timer %d modified (%s)", timer->Index() + 1, timer->active ? "active" : "inactive");
|
isyslog("timer %d %s (%s)", timer->Index() + 1, addIfConfirmed ? "added" : "modified", timer->active ? "active" : "inactive");
|
||||||
|
addIfConfirmed = false;
|
||||||
}
|
}
|
||||||
deleteIfCancelled = false;
|
|
||||||
}
|
}
|
||||||
return osBack;
|
return osBack;
|
||||||
case kRed:
|
case kRed:
|
||||||
@ -1034,19 +1034,14 @@ eOSState cMenuTimers::Edit(void)
|
|||||||
if (HasSubMenu() || Count() == 0)
|
if (HasSubMenu() || Count() == 0)
|
||||||
return osContinue;
|
return osContinue;
|
||||||
isyslog("editing timer %d", CurrentTimer()->Index() + 1);
|
isyslog("editing timer %d", CurrentTimer()->Index() + 1);
|
||||||
return AddSubMenu(new cMenuEditTimer(CurrentTimer()->Index()));
|
return AddSubMenu(new cMenuEditTimer(CurrentTimer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
eOSState cMenuTimers::New(void)
|
eOSState cMenuTimers::New(void)
|
||||||
{
|
{
|
||||||
if (HasSubMenu())
|
if (HasSubMenu())
|
||||||
return osContinue;
|
return osContinue;
|
||||||
cTimer *timer = new cTimer;
|
return AddSubMenu(new cMenuEditTimer(new cTimer, true));
|
||||||
Timers.Add(timer);
|
|
||||||
Add(new cMenuTimerItem(timer), true);
|
|
||||||
Timers.Save();
|
|
||||||
isyslog("timer %d added", timer->Index() + 1);
|
|
||||||
return AddSubMenu(new cMenuEditTimer(timer->Index(), true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
eOSState cMenuTimers::Delete(void)
|
eOSState cMenuTimers::Delete(void)
|
||||||
@ -1095,8 +1090,7 @@ eOSState cMenuTimers::Summary(void)
|
|||||||
|
|
||||||
eOSState cMenuTimers::ProcessKey(eKeys Key)
|
eOSState cMenuTimers::ProcessKey(eKeys Key)
|
||||||
{
|
{
|
||||||
cTimer *ti = HasSubMenu() ? CurrentTimer() : NULL;
|
int TimerNumber = HasSubMenu() ? Count() : -1;
|
||||||
int TimerNumber = ti ? ti->Index() : -1;
|
|
||||||
eOSState state = cOsdMenu::ProcessKey(Key);
|
eOSState state = cOsdMenu::ProcessKey(Key);
|
||||||
|
|
||||||
if (state == osUnknown) {
|
if (state == osUnknown) {
|
||||||
@ -1113,9 +1107,9 @@ eOSState cMenuTimers::ProcessKey(eKeys Key)
|
|||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (TimerNumber >= 0 && !HasSubMenu() && !Timers.Get(TimerNumber)) {
|
if (TimerNumber >= 0 && !HasSubMenu() && Timers.Get(TimerNumber)) {
|
||||||
// a newly created timer wasn't confirmed with Ok
|
// a newly created timer was confirmed with Ok
|
||||||
cOsdMenu::Del(Current());
|
Add(new cMenuTimerItem(Timers.Get(TimerNumber)), true);
|
||||||
Display();
|
Display();
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
@ -1275,16 +1269,11 @@ eOSState cMenuWhatsOn::Record(void)
|
|||||||
if (item) {
|
if (item) {
|
||||||
cTimer *timer = new cTimer(item->eventInfo);
|
cTimer *timer = new cTimer(item->eventInfo);
|
||||||
cTimer *t = Timers.GetTimer(timer);
|
cTimer *t = Timers.GetTimer(timer);
|
||||||
if (!t) {
|
if (t) {
|
||||||
Timers.Add(timer);
|
|
||||||
Timers.Save();
|
|
||||||
isyslog("timer %d added", timer->Index() + 1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
delete timer;
|
delete timer;
|
||||||
timer = t;
|
timer = t;
|
||||||
}
|
}
|
||||||
return AddSubMenu(new cMenuEditTimer(timer->Index(), !t));
|
return AddSubMenu(new cMenuEditTimer(timer, !t));
|
||||||
}
|
}
|
||||||
return osContinue;
|
return osContinue;
|
||||||
}
|
}
|
||||||
@ -1409,16 +1398,11 @@ eOSState cMenuSchedule::Record(void)
|
|||||||
if (item) {
|
if (item) {
|
||||||
cTimer *timer = new cTimer(item->eventInfo);
|
cTimer *timer = new cTimer(item->eventInfo);
|
||||||
cTimer *t = Timers.GetTimer(timer);
|
cTimer *t = Timers.GetTimer(timer);
|
||||||
if (!t) {
|
if (t) {
|
||||||
Timers.Add(timer);
|
|
||||||
Timers.Save();
|
|
||||||
isyslog("timer %d added", timer->Index() + 1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
delete timer;
|
delete timer;
|
||||||
timer = t;
|
timer = t;
|
||||||
}
|
}
|
||||||
return AddSubMenu(new cMenuEditTimer(timer->Index(), !t));
|
return AddSubMenu(new cMenuEditTimer(timer, !t));
|
||||||
}
|
}
|
||||||
return osContinue;
|
return osContinue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user