Bug 1594083 - Check if we got the pref service before using it to avoid a crash r=mhowell

Differential Revision: https://phabricator.services.mozilla.com/D59016

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tom Ritter 2020-01-07 22:19:52 +00:00
Родитель e789bfccec
Коммит 7f4ece010f
1 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -72,8 +72,14 @@ Fuzzyfox::Fuzzyfox()
sFuzzyfoxInitializing = fuzzyfoxEnabled;
// Should I see if these fail? And do what?
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (!prefs) {
// Sometimes the call to the pref service fails. If that happens, we
// don't add the observers. The user will have to restart to have
// preference changes take effect.
return;
}
prefs->AddObserver(FUZZYFOX_ENABLED_PREF, this, false);
prefs->AddObserver(FUZZYFOX_CLOCKGRAIN_PREF, this, false);
}