Bug 918223 - make sure to save persdict.dat, r=ehsan

--HG--
extra : rebase_source : baffbf457b4eb9a1874ddfdda7dce1763a713a30
This commit is contained in:
Olli Pettay 2013-09-19 22:27:03 +03:00
parent 7ee5f54d35
commit 7cad0ddfcd

View File

@ -58,14 +58,15 @@ mozPersonalDictionary::~mozPersonalDictionary()
nsresult mozPersonalDictionary::Init()
{
nsresult rv;
nsCOMPtr<nsIObserverService> svc =
do_GetService("@mozilla.org/observer-service;1", &rv);
if (NS_SUCCEEDED(rv) && svc)
rv = svc->AddObserver(this, "profile-do-change", true); // we want to reload the dictionary if the profile switches
nsCOMPtr<nsIObserverService> svc =
do_GetService("@mozilla.org/observer-service;1");
if (NS_FAILED(rv)) return rv;
NS_ENSURE_STATE(svc);
// we want to reload the dictionary if the profile switches
nsresult rv = svc->AddObserver(this, "profile-do-change", true);
NS_ENSURE_SUCCESS(rv, rv);
rv = svc->AddObserver(this, "profile-before-change", true);
NS_ENSURE_SUCCESS(rv, rv);
Load();
@ -256,6 +257,8 @@ NS_IMETHODIMP mozPersonalDictionary::Observe(nsISupports *aSubject, const char *
{
if (!nsCRT::strcmp(aTopic, "profile-do-change")) {
Load(); // load automatically clears out the existing dictionary table
} else if (!nsCRT::strcmp(aTopic, "profile-before-change")) {
Save();
}
return NS_OK;