Commit 3e8de095 authored by Kurt Hindenburg's avatar Kurt Hindenburg
Browse files

Fix issue when edits current profile when using the builtin/fallback

Since we no longer ship Shell.profile, if there are no profiles and
the user edits the current profile it actually tries to change the
built-in/fallback profile.  Now a new correct profile is created.
parent 48a3ff81
......@@ -336,22 +336,16 @@ void ProfileManager::changeProfile(Profile::Ptr profile,
// insert the changes into the existing Profile instance
QListIterator<Profile::Property> iter(propertyMap.keys());
while (iter.hasNext()) {
const Profile::Property property =;
profile->setProperty(property, propertyMap[property]);
// never save a profile with empty name into disk!
persistent = persistent && !profile->name().isEmpty();
Profile::Ptr newProfile;
// If we are asked to store the fallback profile (which has an
// invalid path by design), we reset the path to an empty string
// which will make the profile writer automatically generate a
// proper path.
if (persistent && profile->path() == _fallbackProfile->path()) {
profile = new Profile(profile);
// Generate a new name, so it is obvious what is actually built-in
// in the profile manager
......@@ -367,14 +361,30 @@ void ProfileManager::changeProfile(Profile::Ptr profile,
do {
newName = QStringLiteral("Profile ") + QString::number(nameSuffix);
newTranslatedName = i18nc("The default name of a profile", "Profile #%1", nameSuffix);
// TODO: remove the # above and below - too many issues
} while (existingProfileNames.contains(newName));
profile->setProperty(Profile::UntranslatedName, newName);
profile->setProperty(Profile::Name, newTranslatedName);
newProfile = Profile::Ptr(new Profile(ProfileManager::instance()->fallbackProfile()));
newProfile->clone(profile, true);
newProfile->setProperty(Profile::UntranslatedName, newName);
newProfile->setProperty(Profile::Name, newTranslatedName);
newProfile->setProperty(Profile::MenuIndex, QString("0"));
} else {
newProfile = profile;
// insert the changes into the existing Profile instance
QListIterator<Profile::Property> iter(propertyMap.keys());
while (iter.hasNext()) {
const Profile::Property property =;
newProfile->setProperty(property, propertyMap[property]);
// when changing a group, iterate through the profiles
......@@ -383,22 +393,22 @@ void ProfileManager::changeProfile(Profile::Ptr profile,
// this is so that each profile in the group, the profile is
// applied, a change notification is emitted and the profile
// is saved to disk
ProfileGroup::Ptr group = profile->asGroup();
ProfileGroup::Ptr group = newProfile->asGroup();
if (group) {
foreach(const Profile::Ptr & profile, group->profiles()) {
changeProfile(profile, propertyMap, persistent);
foreach(const Profile::Ptr & newProfile, group->profiles()) {
changeProfile(newProfile, propertyMap, persistent);
// save changes to disk, unless the profile is hidden, in which case
// it has no file on disk
if (persistent && !profile->isHidden()) {
profile->setProperty(Profile::Path, saveProfile(profile));
if (persistent && !newProfile->isHidden()) {
newProfile->setProperty(Profile::Path, saveProfile(newProfile));
// notify the world about the change
emit profileChanged(profile);
emit profileChanged(newProfile);
void ProfileManager::addProfile(Profile::Ptr profile)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment