From 67a473f7d506bec0c8a64779c0c3fc9dd9baa9cc Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 22 Jan 2011 19:06:15 +0000 Subject: [PATCH] CID 10361: Slight code simplification to remove superfluous for loop. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40266 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/tracker/StatusWindow.cpp | 49 +++++++++++++------------------ 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/src/kits/tracker/StatusWindow.cpp b/src/kits/tracker/StatusWindow.cpp index 8fe4852973..4ec3f6d35d 100644 --- a/src/kits/tracker/StatusWindow.cpp +++ b/src/kits/tracker/StatusWindow.cpp @@ -356,38 +356,29 @@ BStatusWindow::CheckCanceledOrPaused(thread_id thread) BStatusView* view = NULL; - for (;;) { - - AutoLock lock(this); - // check if cancel or pause hit - for (int32 index = fViewList.CountItems() - 1; index >= 0; index--) { - - view = fViewList.ItemAt(index); - if (view && view->Thread() == thread) { - isPaused = view->IsPaused(); - wasCanceled = view->WasCanceled(); - break; - } - } - lock.Unlock(); - - if (wasCanceled || !isPaused) + AutoLock lock(this); + // check if cancel or pause hit + for (int32 index = fViewList.CountItems() - 1; index >= 0; index--) { + view = fViewList.ItemAt(index); + if (view && view->Thread() == thread) { + isPaused = view->IsPaused(); + wasCanceled = view->WasCanceled(); break; - - if (isPaused && view != NULL) { - AutoLock lock(this); - // say we are paused - view->Invalidate(); - lock.Unlock(); - - ASSERT(find_thread(NULL) == view->Thread()); - - // and suspend ourselves - // we will get resumend from BStatusView::MessageReceived - suspend_thread(view->Thread()); } - break; + } + if (wasCanceled || !isPaused) + return wasCanceled; + + if (isPaused && view != NULL) { + // say we are paused + view->Invalidate(); + + ASSERT(find_thread(NULL) == view->Thread()); + + // and suspend ourselves + // we will get resumed from BStatusView::MessageReceived + suspend_thread(view->Thread()); } return wasCanceled;