From 10e37f6b8e8c946cecfefbaae8b14369e695d8e9 Mon Sep 17 00:00:00 2001 From: louis Date: Thu, 16 Jul 2015 18:08:22 +0200 Subject: [PATCH] some more locks --- views/displaymenulistview.c | 2 ++ views/view.c | 2 ++ views/viewhelpers.c | 29 ++++++++++++++++++++++++++--- views/viewhelpers.h | 1 + 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/views/displaymenulistview.c b/views/displaymenulistview.c index 1c4fa2b..29927b2 100644 --- a/views/displaymenulistview.c +++ b/views/displaymenulistview.c @@ -224,6 +224,7 @@ void cDisplayMenuListView::Render(void) { } int current = -1; for (int i=0; iDirty()) { menuItems[i]->Clear(); menuItems[i]->SetNumber(i); @@ -236,6 +237,7 @@ void cDisplayMenuListView::Render(void) { menuItems[i]->Stop(); } } + Unlock(); } if (current > -1) { menuItems[current]->Start(); diff --git a/views/view.c b/views/view.c index de28cfc..ad1635c 100644 --- a/views/view.c +++ b/views/view.c @@ -1191,6 +1191,8 @@ void cViewElement::Action(void) { DoFlush(); if (scrolling) { DoSleep(scrollDelay); + if (!Running()) + return; if (scrollOrientation == orHorizontal) { ScrollHorizontal(scrollingPix, scrollDelay, scrollSpeed, scrollMode); } else { diff --git a/views/viewhelpers.c b/views/viewhelpers.c index 972c607..45101d3 100644 --- a/views/viewhelpers.c +++ b/views/viewhelpers.c @@ -32,9 +32,14 @@ cViewHelpers::cViewHelpers(void) { cViewHelpers::~cViewHelpers() { if (devicesInit) { + mutexDevices.Lock(); delete[] lastSignalStrength; + lastSignalStrength = NULL; delete[] lastSignalQuality; + lastSignalQuality = NULL; delete[] recDevices; + recDevices = NULL; + mutexDevices.Unlock(); } } @@ -309,11 +314,13 @@ void cViewHelpers::InitDevices(void) { lastSignalStrength = new int[numDevices]; lastSignalQuality = new int[numDevices]; recDevices = new bool[numDevices]; + mutexDevices.Lock(); for (int i=0; iSignalStrength(); int signalQuality = device->SignalQuality(); - if ((signalStrength != lastSignalStrength[i]) || (signalQuality != lastSignalQuality[i])) { + int lastSigStr = 0; + int lastSigQual = 0; + mutexDevices.Lock(); + if (lastSignalStrength && lastSignalQuality) { + lastSigStr = lastSignalStrength[i]; + lastSigQual = lastSignalQuality[i]; + } + mutexDevices.Unlock(); + if ((signalStrength != lastSigStr) || (signalQuality != lastSigQual)) { changed = true; break; } @@ -356,7 +371,10 @@ bool cViewHelpers::SetDevices(bool initial, bool light, intmap *intTokens, vecto if (cRecordControl *RecordControl = cRecordControls::GetRecordControl(timer)) { const cDevice *recDevice = RecordControl->Device(); if (recDevice) { - recDevices[recDevice->DeviceNumber()] = true; + mutexDevices.Lock(); + if (recDevices) + recDevices[recDevice->DeviceNumber()] = true; + mutexDevices.Unlock(); } } } @@ -399,7 +417,12 @@ bool cViewHelpers::SetDevices(bool initial, bool light, intmap *intTokens, vecto deviceVals.insert(pair< string, string >("devices[signalquality]", strQuality.str())); deviceVals.insert(pair< string, string >("devices[livetv]", i == deviceLiveTV ? "1" : "0")); - deviceVals.insert(pair< string, string >("devices[recording]", recDevices[i] ? "1" : "0")); + string isRecording = "0"; + mutexDevices.Lock(); + if (recDevices && recDevices[i]) + isRecording = "1"; + mutexDevices.Unlock(); + deviceVals.insert(pair< string, string >("devices[recording]", isRecording)); const cChannel *channel = device->GetCurrentlyTunedTransponder(); const cSource *source = (channel) ? Sources.Get(channel->Source()) : NULL; diff --git a/views/viewhelpers.h b/views/viewhelpers.h index 7dc191e..1baf4e0 100644 --- a/views/viewhelpers.h +++ b/views/viewhelpers.h @@ -9,6 +9,7 @@ typedef pair stringpair; class cViewHelpers { private: + cMutex mutexDevices; int numDevices; bool devicesInit; int* lastSignalStrength;