From 2617261d775301611d0312f8122a48feab49a478 Mon Sep 17 00:00:00 2001 From: Karsten Heimrich Date: Sun, 5 Oct 2008 01:26:06 +0000 Subject: [PATCH] * fix a nasty bug i introduced with 26383, leaving the looper locked * grab the fLooper pointer in some more functions, just to play save * remove wrong comment in UnlockLooper, since it's obviously possible to change fLooper In case we remove the handler from the loopers handler list, we need to grab the looper pointer first, since calling RemoveHandler(...) will call BHandler::SetLooper(...) thus setting fLooper to NULL and calling UnlockLooper did nothing, leaving the looper locked. Thanks Maurice for pointing out that 26383 broke Cortex, the wires where not draw and the app was locked somehow. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27872 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/app/Handler.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/kits/app/Handler.cpp b/src/kits/app/Handler.cpp index 0373708fd9..179ae7e0f6 100644 --- a/src/kits/app/Handler.cpp +++ b/src/kits/app/Handler.cpp @@ -132,8 +132,9 @@ BHandler::BHandler(const char *name) BHandler::~BHandler() { if (LockLooper()) { - Looper()->RemoveHandler(this); - UnlockLooper(); + BLooper* looper = Looper(); + looper->RemoveHandler(this); + looper->Unlock(); } // remove all filters @@ -331,13 +332,14 @@ BHandler::NextHandler() const void BHandler::AddFilter(BMessageFilter *filter) { - if (fLooper && !fLooper->IsLocked()) { + BLooper* looper = fLooper; + if (looper && !looper->IsLocked()) { debugger("Owning Looper must be locked before calling SetFilterList"); return; } - if (fLooper != NULL) - filter->SetLooper(fLooper); + if (looper != NULL) + filter->SetLooper(looper); if (!fFilters) fFilters = new BList; @@ -349,7 +351,8 @@ BHandler::AddFilter(BMessageFilter *filter) bool BHandler::RemoveFilter(BMessageFilter *filter) { - if (fLooper && !fLooper->IsLocked()) { + BLooper* looper = fLooper; + if (looper && !looper->IsLocked()) { debugger("Owning Looper must be locked before calling SetFilterList"); return false; } @@ -366,7 +369,8 @@ BHandler::RemoveFilter(BMessageFilter *filter) void BHandler::SetFilterList(BList* filters) { - if (fLooper && !fLooper->IsLocked()) { + BLooper* looper = fLooper; + if (looper && !looper->IsLocked()) { debugger("Owning Looper must be locked before calling SetFilterList"); return; } @@ -391,7 +395,7 @@ BHandler::SetFilterList(BList* filters) BMessageFilter *filter = static_cast(fFilters->ItemAt(i)); if (filter != NULL) - filter->SetLooper(fLooper); + filter->SetLooper(looper); } } } @@ -447,9 +451,7 @@ BHandler::LockLooperWithTimeout(bigtime_t timeout) void BHandler::UnlockLooper() { - // The looper is locked at this point, and cannot change - if (fLooper != NULL) - fLooper->Unlock(); + fLooper->Unlock(); }