summaryrefslogtreecommitdiffstats
path: root/toolkit/xre/nsAppRunner.cpp
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-19 14:21:10 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-19 14:21:10 +0200
commit54c479af3a81f09be57465185d56ab1217a8b47f (patch)
treec2419338ff7c06aca466dca3649ce0f98183caef /toolkit/xre/nsAppRunner.cpp
parente3d08de2d29be507fcd5c73c328572167fe43af7 (diff)
downloadUXP-54c479af3a81f09be57465185d56ab1217a8b47f.tar
UXP-54c479af3a81f09be57465185d56ab1217a8b47f.tar.gz
UXP-54c479af3a81f09be57465185d56ab1217a8b47f.tar.lz
UXP-54c479af3a81f09be57465185d56ab1217a8b47f.tar.xz
UXP-54c479af3a81f09be57465185d56ab1217a8b47f.zip
Bug 1122124: Fix default profile setting after reset, keep profile name
Native in moebius https://github.com/MoonchildProductions/moebius/pull/184
Diffstat (limited to 'toolkit/xre/nsAppRunner.cpp')
-rw-r--r--toolkit/xre/nsAppRunner.cpp39
1 files changed, 25 insertions, 14 deletions
diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
index 530e4a353..9fb20e5e2 100644
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -1886,17 +1886,20 @@ ShowProfileManager(nsIToolkitProfileService* aProfileSvc,
}
/**
- * Set the currently running profile as the default/selected one.
+ * Get the currently running profile using its root directory.
*
+ * @param aProfileSvc The profile service
* @param aCurrentProfileRoot The root directory of the current profile.
- * @return an error if aCurrentProfileRoot is not found or the profile could not
- * be set as the default.
+ * @param aProfile Out-param that returns the profile object.
+ * @return an error if aCurrentProfileRoot is not found
*/
static nsresult
-SetCurrentProfileAsDefault(nsIToolkitProfileService* aProfileSvc,
- nsIFile* aCurrentProfileRoot)
+GetCurrentProfile(nsIToolkitProfileService* aProfileSvc,
+ nsIFile* aCurrentProfileRoot,
+ nsIToolkitProfile** aProfile)
{
NS_ENSURE_ARG_POINTER(aProfileSvc);
+ NS_ENSURE_ARG_POINTER(aProfile);
nsCOMPtr<nsISimpleEnumerator> profiles;
nsresult rv = aProfileSvc->GetProfiles(getter_AddRefs(profiles));
@@ -1912,7 +1915,8 @@ SetCurrentProfileAsDefault(nsIToolkitProfileService* aProfileSvc,
profile->GetRootDir(getter_AddRefs(profileRoot));
profileRoot->Equals(aCurrentProfileRoot, &foundMatchingProfile);
if (foundMatchingProfile) {
- return aProfileSvc->SetSelectedProfile(profile);
+ profile.forget(aProfile);
+ return NS_OK;
}
rv = profiles->GetNext(getter_AddRefs(supports));
}
@@ -3749,15 +3753,22 @@ XREMain::XRE_mainRun()
nsresult backupCreated = ProfileResetCleanup(profileBeingReset);
if (NS_FAILED(backupCreated)) NS_WARNING("Could not cleanup the profile that was reset");
- // 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) {
- // this is actually "broken" - see bug 1122124
- rv = SetCurrentProfileAsDefault(mProfileSvc, mProfD);
- if (NS_FAILED(rv)) NS_WARNING("Could not set current profile as the default");
+ nsCOMPtr<nsIToolkitProfile> newProfile;
+ rv = GetCurrentProfile(mProfileSvc, mProfD, getter_AddRefs(newProfile));
+ if (NS_SUCCEEDED(rv)) {
+ newProfile->SetName(gResetOldProfileName);
+ // 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) {
+ rv = mProfileSvc->SetDefaultProfile(newProfile);
+ if (NS_FAILED(rv)) NS_WARNING("Could not set current profile as the default");
+ }
+ } else {
+ NS_WARNING("Could not find current profile to set as default / change name.");
}
- // Need to write out the fact that the profile has been removed and potentially
- // that the selected/default profile changed.
+
+ // Need to write out the fact that the profile has been removed, the new profile
+ // renamed, and potentially that the selected/default profile changed.
mProfileSvc->Flush();
}
}