From 6df4d96ed17c3ffddc5e9aa8bfd242be2b8f944b Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Tue, 4 Mar 2025 16:27:49 +0100 Subject: [PATCH] Added a mutex lock to protect creating/deleting cEpgHandler objects --- CONTRIBUTORS | 3 ++- HISTORY | 4 ++-- epg.c | 8 +++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 0c456e75..3a6fb5b3 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -2596,7 +2596,8 @@ Markus Ehrnsperger for implementing cStatus::OsdCurrentItem2() with the index of the current item for adding missing calls to cStatus::MsgOsdStatusMessage() and implementing cStatus::OsdStatusMessage2() with the type of the message - for suggesting to add a mutex lock to protect creating/deleting cStatus objects + for suggesting to add mutex locks to protect creating/deleting cStatus and cEpgHandler + objects Werner Färber for reporting a bug in handling the cPluginManager::Active() result when pressing diff --git a/HISTORY b/HISTORY index c0de021a..3d43da2a 100644 --- a/HISTORY +++ b/HISTORY @@ -10100,7 +10100,7 @@ Video Disk Recorder Revision History Plugins that use these recently introduced functions need to remove the '2' from the name. - The new virtual function cSkinDisplayMenu::SetItemEvent(..., const cTimer *Timer) can be used to get full access to the timer (if any) defined for this event. -- Added a mutex lock to protect creating/deleting cStatus objects (suggested by Markus - Ehrnsperger). +- Added mutex locks to protect creating/deleting cStatus and cEpgHandler objects (suggested + by Markus Ehrnsperger). - Making absolutely sure cEvent::Title() never returns NULL. APIVERSNUM is now 30007. diff --git a/epg.c b/epg.c index 5b0fea4f..db6a49f8 100644 --- a/epg.c +++ b/epg.c @@ -7,7 +7,7 @@ * Original version (as used in VDR before 1.3.0) written by * Robert Schneider and Rolf Hakenes . * - * $Id: epg.c 5.14 2025/03/02 11:03:35 kls Exp $ + * $Id: epg.c 5.15 2025/03/04 16:27:49 kls Exp $ */ #include "epg.h" @@ -1421,14 +1421,20 @@ void cEpgDataReader::Action(void) // --- cEpgHandler ----------------------------------------------------------- +static cMutex Mutex; + cEpgHandler::cEpgHandler(void) { + Mutex.Lock(); EpgHandlers.Add(this); + Mutex.Unlock(); } cEpgHandler::~cEpgHandler() { + Mutex.Lock(); EpgHandlers.Del(this, false); + Mutex.Unlock(); } // --- cEpgHandlers ----------------------------------------------------------