Bug 1265368 - ensure we flush even if we're not marking the profile as default, r?MattN draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 05 May 2016 21:33:23 +0100
changeset 363945 bfdd391e0254bd3b2b7a2da1ae87f7a439016392
parent 363944 e1a6ce0a05ccd6ef94026c6fdeaf6421d5cffe03
child 363946 d2c8e237de0809d571d83cf6658fda150863b0b3
push id17339
push usergijskruitbosch@gmail.com
push dateThu, 05 May 2016 20:43:07 +0000
reviewersMattN
bugs1265368
milestone49.0a1
Bug 1265368 - ensure we flush even if we're not marking the profile as default, r?MattN MozReview-Commit-ID: EgGcbHHOCf2
toolkit/xre/nsAppRunner.cpp
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -2231,21 +2231,18 @@ SetCurrentProfileAsSelected(nsIToolkitPr
   bool foundMatchingProfile = false;
   nsCOMPtr<nsISupports> supports;
   rv = profiles->GetNext(getter_AddRefs(supports));
   while (NS_SUCCEEDED(rv)) {
     nsCOMPtr<nsIToolkitProfile> profile = do_QueryInterface(supports);
     nsCOMPtr<nsIFile> profileRoot;
     profile->GetRootDir(getter_AddRefs(profileRoot));
     profileRoot->Equals(aCurrentProfileRoot, &foundMatchingProfile);
-    if (foundMatchingProfile && profile) {
-      rv = aProfileSvc->SetSelectedProfile(profile);
-      if (NS_SUCCEEDED(rv))
-        rv = aProfileSvc->Flush();
-      return rv;
+    if (foundMatchingProfile) {
+      return aProfileSvc->SetSelectedProfile(profile);
     }
     rv = profiles->GetNext(getter_AddRefs(supports));
   }
   return rv;
 }
 
 static bool gDoMigration = false;
 static bool gDoProfileReset = false;
@@ -4202,16 +4199,19 @@ XREMain::XRE_mainRun()
 
       // Set the new profile as the default after we're done cleaning up the old profile,
       // iff that profile was already the default
       if (profileWasSelected) {
         //XXXgijs this is actually "broken" - see bug 1270615
         rv = SetCurrentProfileAsSelected(mProfileSvc, mProfD);
         if (NS_FAILED(rv)) NS_WARNING("Could not set current profile as the default");
       }
+      // Need to write out the fact that the profile has been removed and potentially
+      // that the selected/default profile changed.
+      mProfileSvc->Flush();
     }
   }
 
   mDirProvider.DoStartup();
 
   OverrideDefaultLocaleIfNeeded();
 
 #ifdef MOZ_CRASHREPORTER