From a9ab16e27c0181f0c12e9d09413526ff5df3d0e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 4 Aug 2008 21:16:11 +0000 Subject: [PATCH] * Move the LockLooper() call before PathHandler::Quit() into Quit(). * The B_QUIT_REQUESTED message never arrived for me unless I unlock the BLooper again, then it works as expected. * The B_QUIT_REQUESTED handling accessed fOwnsLooper after deleting the object. (Review much welcome - I don't understand the purpose of locking the BLooper at all before trying to use a BMessenger to send it a message.) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26805 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/storage/PathMonitor.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/kits/storage/PathMonitor.cpp b/src/kits/storage/PathMonitor.cpp index c882ebe02f..9cfba93a6d 100644 --- a/src/kits/storage/PathMonitor.cpp +++ b/src/kits/storage/PathMonitor.cpp @@ -212,8 +212,13 @@ PathHandler::InitCheck() const void PathHandler::Quit() { + if (!LockLooper()) + return; + BMessenger me(this); me.SendMessage(B_QUIT_REQUESTED); + + UnlockLooper(); } @@ -484,13 +489,16 @@ PathHandler::MessageReceived(BMessage* message) case B_QUIT_REQUESTED: { BLooper* looper = Looper(); + bool ownsLooper = fOwnsLooper; stop_watching(this); looper->RemoveHandler(this); delete this; - if (fOwnsLooper) + if (ownsLooper) { + looper->Lock(); looper->Quit(); + } return; } @@ -833,8 +841,7 @@ BPathMonitor::StopWatching(const char* path, BMessenger target) PathHandler* handler = i->second; watcher->handlers.erase(i); - if (handler->LockLooper()) - handler->Quit(); + handler->Quit(); if (watcher->handlers.empty()) { sWatchers.erase(iterator); @@ -863,8 +870,7 @@ BPathMonitor::StopWatching(BMessenger target) PathHandler* handler = i->second; watcher->handlers.erase(i); - if (handler->LockLooper()) - handler->Quit(); + handler->Quit(); } sWatchers.erase(iterator);