diff --git a/toolkit/content/aboutProfiles.js b/toolkit/content/aboutProfiles.js index 3b02da1f89c7..fa414401f934 100644 --- a/toolkit/content/aboutProfiles.js +++ b/toolkit/content/aboutProfiles.js @@ -298,6 +298,31 @@ function removeProfile(profile) { } } + // If we are deleting the selected or the default profile we must choose a + // different one. + let isSelected = ProfileService.selectedProfile == profile; + let isDefault = ProfileService.defaultProfile == profile; + + if (isSelected || isDefault) { + let itr = ProfileService.profiles; + while(itr.hasMoreElements()) { + let p = itr.getNext().QueryInterface(Ci.nsIToolkitProfile); + if (profile == p) { + continue; + } + + if (isSelected) { + ProfileService.selectedProfile = p; + } + + if (isDefault) { + ProfileService.defaultProfile = p; + } + + break; + } + } + profile.remove(deleteFiles); ProfileService.flush(); refreshUI();