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.
This commit is contained in:
Adrien Destugues
2020-08-05 15:39:19 +02:00
parent 9027ca04e2
commit 0d1f89e1a3
+2 -2
View File
@@ -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();
}