diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2016-12-11 13:06:58 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2016-12-11 13:06:58 +0100 |
commit | a9bd3ca0dc06c9a6439f5e484e137fc6aa50b4bc (patch) | |
tree | 49cb44825827e1d45a18d18e932ce86b68f9f50d /menu.c | |
parent | 031bbcef40cada90ff344511d4c06d67d11f0b83 (diff) | |
download | vdr-a9bd3ca0dc06c9a6439f5e484e137fc6aa50b4bc.tar.gz vdr-a9bd3ca0dc06c9a6439f5e484e137fc6aa50b4bc.tar.bz2 |
Fixed a crash when deleting a recording that is currently being replayed
Diffstat (limited to 'menu.c')
-rw-r--r-- | menu.c | 39 |
1 files changed, 17 insertions, 22 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.c 4.16 2016/12/09 14:54:24 kls Exp $ + * $Id: menu.c 4.17 2016/12/11 12:43:55 kls Exp $ */ #include "menu.h" @@ -3089,29 +3089,24 @@ eOSState cMenuRecordings::Delete(void) else return osContinue; } - cRecordings *Recordings = cRecordings::GetRecordingsWrite(recordingsStateKey); - Recordings->SetExplicitModify(); - cRecording *Recording = Recordings->GetByName(ri->Recording()->FileName()); - if (!Recording) { - Skins.Message(mtWarning, tr("Recording vanished!")); - recordingsStateKey.Remove(); - return osContinue; - } - cString FileName = Recording->FileName(); - if (RecordingsHandler.GetUsage(FileName)) { - if (Interface->Confirm(tr("Recording is being edited - really delete?"))) { - RecordingsHandler.Del(FileName); - Recording = Recordings->GetByName(FileName); // RecordingsHandler.Del() might have deleted it if it was the edited version - // we continue with the code below even if Recording is NULL, - // in order to have the menu updated etc. - } - else { - recordingsStateKey.Remove(); - return osContinue; - } - } + cString FileName; + { + LOCK_RECORDINGS_READ; + if (const cRecording *Recording = Recordings->GetByName(ri->Recording()->FileName())) { + FileName = Recording->FileName(); + if (RecordingsHandler.GetUsage(FileName)) { + if (Interface->Confirm(tr("Recording is being edited - really delete?"))) + RecordingsHandler.Del(FileName); + else + return osContinue; + } + } + } if (cReplayControl::NowReplaying() && strcmp(cReplayControl::NowReplaying(), FileName) == 0) cControl::Shutdown(); + cRecordings *Recordings = cRecordings::GetRecordingsWrite(recordingsStateKey); + Recordings->SetExplicitModify(); + cRecording *Recording = Recordings->GetByName(FileName); if (!Recording || Recording->Delete()) { cReplayControl::ClearLastReplayed(FileName); Recordings->DelByName(FileName); |