From 0d1f89e1a35d2a5df2d5140bc8d81f054804205d Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 5 Aug 2020 15:39:19 +0200 Subject: [PATCH] TranslatorRoster: avoid a deadlock when launching BeLive If be_app is not running yet, trying to lock it may easily end up in a deadlock. Fixes #2105 However, as a result of this, when this situation happens, the translator roster will not be node monitoring added/removed translators. This was already the case if BTranslatorRoster::Default was called before BApplication constructor, now it's also the case if called inside the BApplication constructor or from another thread before it finished running. Maybe BTranslatorRoster should try to register itself later on if it detects this. But it's acceptable to have the app not monitor translators, because adding and removing translators isn't a very common occurence and restarting the app to get it to notice them is probably ok. --- src/kits/translation/TranslatorRoster.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kits/translation/TranslatorRoster.cpp b/src/kits/translation/TranslatorRoster.cpp index 8ac563caa0..c54be30e9d 100644 --- a/src/kits/translation/TranslatorRoster.cpp +++ b/src/kits/translation/TranslatorRoster.cpp @@ -168,8 +168,8 @@ BTranslatorRoster::Private::Private() } } - // we're sneaking us into the BApplication - if (be_app != NULL && be_app->Lock()) { + // we're sneaking ourselves into the BApplication, if it's running + if (be_app != NULL && !be_app->IsLaunching() && be_app->Lock()) { be_app->AddHandler(this); be_app->Unlock(); }