From ad7255c892e74412e4a0f860aac1db65bb978abf Mon Sep 17 00:00:00 2001 From: Dario Casalinuovo Date: Mon, 14 Nov 2016 19:06:57 +0100 Subject: [PATCH] MediaRoster: Use messaging instead to call Quit on exit * As far as the bebook states loopers shouldn't be quit from other threads, using a B_QUIT_REQUESTED message should be more safe. --- src/kits/media/MediaRoster.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/kits/media/MediaRoster.cpp b/src/kits/media/MediaRoster.cpp index b62dce518c..c928736a7a 100644 --- a/src/kits/media/MediaRoster.cpp +++ b/src/kits/media/MediaRoster.cpp @@ -119,8 +119,7 @@ public: ~MediaRosterUndertaker() { BAutolock _(sInitLocker); - if (BMediaRoster::CurrentRoster() != NULL - && BMediaRoster::CurrentRoster()->Lock()) { + if (BMediaRoster::CurrentRoster() != NULL) { // Detect any forgotten node if (sRegisteredNodes.CountItems() > 0) { @@ -137,7 +136,14 @@ public: if (be_app != NULL) be_app->UnregisterLooper(BMediaRoster::CurrentRoster()); - BMediaRoster::CurrentRoster()->Quit(); + status_t err = B_ERROR; + thread_id roster = BMediaRoster::CurrentRoster()->Thread(); + + BMediaRoster::CurrentRoster()->PostMessage(B_QUIT_REQUESTED); + + wait_for_thread(roster, &err); + if (err != B_OK) + ERROR("BMediaRoster: wait_for_thread returned error"); } } };