summaryrefslogtreecommitdiff
path: root/displaymenu.c
diff options
context:
space:
mode:
authorlouis <louis.braun@gmx.de>2012-12-05 21:06:52 +0100
committerlouis <louis.braun@gmx.de>2012-12-05 21:06:52 +0100
commit5dff51292c2d08b38db010dfe291c1e829e1945f (patch)
tree080b36357be6465827ab667ddaba9516ac345f1a /displaymenu.c
parent85b83b42ae87dff1ce984a88779d03698978460b (diff)
downloadskin-nopacity-5dff51292c2d08b38db010dfe291c1e829e1945f.tar.gz
skin-nopacity-5dff51292c2d08b38db010dfe291c1e829e1945f.tar.bz2
Fix Ticket 1147, cancelling threads in a safer way
Diffstat (limited to 'displaymenu.c')
-rw-r--r--displaymenu.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/displaymenu.c b/displaymenu.c
index 46be742..bbd27e1 100644
--- a/displaymenu.c
+++ b/displaymenu.c
@@ -35,10 +35,9 @@ cNopacityDisplayMenu::cNopacityDisplayMenu(void) {
}
cNopacityDisplayMenu::~cNopacityDisplayMenu() {
- if (Running()) {
- Cancel();
- cCondWait::SleepMs(300);
- }
+ Cancel(-1);
+ while (Active())
+ cCondWait::SleepMs(10);
delete menuView;
menuItems.Clear();
if (detailView) {
@@ -472,7 +471,7 @@ void cNopacityDisplayMenu::Flush(void) {
DrawTimers();
}
if (initial) {
- if (FadeTime)
+ if (config.menuFadeTime)
Start();
}
initMenu = false;
@@ -486,21 +485,21 @@ void cNopacityDisplayMenu::Action(void) {
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;
menuView->SetPixmapAlpha(Alpha);
- for (cNopacityMenuItem *item = menuItems.First(); item; item = menuItems.Next(item)) {
+ for (cNopacityMenuItem *item = menuItems.First(); Running() && item; item = menuItems.Next(item)) {
item->SetAlpha(Alpha);
item->SetAlphaIcon(Alpha);
}
- for (cNopacityTimer *t = timers.First(); t; t = timers.Next(t)) {
+ for (cNopacityTimer *t = timers.First(); Running() && t; t = timers.Next(t))
t->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;
- }
+ }
}