diff options
author | louis <louis.braun@gmx.de> | 2012-12-05 21:06:52 +0100 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2012-12-05 21:06:52 +0100 |
commit | 5dff51292c2d08b38db010dfe291c1e829e1945f (patch) | |
tree | 080b36357be6465827ab667ddaba9516ac345f1a /displaychannel.c | |
parent | 85b83b42ae87dff1ce984a88779d03698978460b (diff) | |
download | skin-nopacity-5dff51292c2d08b38db010dfe291c1e829e1945f.tar.gz skin-nopacity-5dff51292c2d08b38db010dfe291c1e829e1945f.tar.bz2 |
Fix Ticket 1147, cancelling threads in a safer way
Diffstat (limited to 'displaychannel.c')
-rw-r--r-- | displaychannel.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/displaychannel.c b/displaychannel.c index ba8102c..563e50b 100644 --- a/displaychannel.c +++ b/displaychannel.c @@ -31,6 +31,9 @@ cNopacityDisplayChannel::cNopacityDisplayChannel(bool WithInfo) { } cNopacityDisplayChannel::~cNopacityDisplayChannel() { + Cancel(-1); + while (Active()) + cCondWait::SleepMs(10); osd->DestroyPixmap(pixmapBackgroundTop); osd->DestroyPixmap(pixmapBackgroundBottom); osd->DestroyPixmap(pixmapLogo); @@ -293,8 +296,7 @@ void cNopacityDisplayChannel::DrawSignal(void) { lastSignalStrength = SignalStrength; lastSignalQuality = SignalQuality; lastSignalDisplay = Now; - } - + } } void cNopacityDisplayChannel::SetChannel(const cChannel *Channel, int Number) { @@ -319,12 +321,12 @@ void cNopacityDisplayChannel::SetChannel(const cChannel *Channel, int Number) { ChannelNumber = cString::sprintf("%d%s", Channel->Number(), Number ? "-" : ""); } else groupSep = true; - } else if (Number) { + } else if (Number) { ChannelNumber = cString::sprintf("%d-", Number); } else { ChannelName = ChannelString(NULL, 0); } - + cString channelString = cString::sprintf("%s %s", *ChannelNumber, *ChannelName); if (!groupSep) { @@ -493,11 +495,11 @@ void cNopacityDisplayChannel::Flush(void) { void cNopacityDisplayChannel::Action(void) { uint64_t Start = cTimeMs::Now(); - while (true) { + while (Running()) { uint64_t Now = cTimeMs::Now(); cPixmap::Lock(); double t = min(double(Now - Start) / FadeTime, 1.0); - int Alpha = t * ALPHA_OPAQUE; + int Alpha = t * ALPHA_OPAQUE; pixmapBackgroundTop->SetAlpha(Alpha); pixmapBackgroundBottom->SetAlpha(Alpha); pixmapLogo->SetAlpha(Alpha); @@ -517,13 +519,14 @@ void cNopacityDisplayChannel::Action(void) { pixmapSignalMeter->SetAlpha(Alpha); pixmapSignalLabel->SetAlpha(Alpha); } - osd->Flush(); + if (Running()) + osd->Flush(); cPixmap::Unlock(); - int Delta = cTimeMs::Now() - Now; - if (Delta < FrameTime) - cCondWait::SleepMs(FrameTime - Delta); + int Delta = cTimeMs::Now() - Now; + if (Running() && (Delta < FrameTime)) + cCondWait::SleepMs(FrameTime - Delta); if ((int)(Now - Start) > FadeTime) { break; } - } + } }
\ No newline at end of file |