Fix 2 issues with Profile->Edit Environment dialog

1. Correctly handle when user removes all lines
2. Correctly handle when user OKs Edit Env dialog and then reopens
   same dialog before closing Edit Profile dialog.

Thanks to ahmadsamir for patch.

Differential Revision: https://phabricator.kde.org/D8921

(cherry picked from commit eaccb7dc61)
wilder-portage
Kurt Hindenburg 8 years ago
parent d6ca6c92e8
commit 5504bf756e
  1. 25
      src/EditProfileDialog.cpp

@ -328,7 +328,17 @@ void EditProfileDialog::showEnvironmentEditor()
{
bool ok;
const Profile::Ptr profile = lookupProfile();
QStringList currentEnvironment = profile->environment();
QStringList currentEnvironment;
// the user could re-open the environment editor before clicking OK/Apply
// in the parent edit profile dialog, so we make sure to show the the new
// environment vars
if (_tempProfile->isPropertySet(Profile::Environment)) {
currentEnvironment = _tempProfile->environment();
} else {
currentEnvironment = profile->environment();
}
QString text = QInputDialog::getMultiLineText(this,
i18n("Edit Environment"),
@ -336,9 +346,16 @@ void EditProfileDialog::showEnvironmentEditor()
currentEnvironment.join(QStringLiteral("\n")),
&ok);
if (ok && !text.isEmpty()) {
QStringList newEnvironment = text.split(QLatin1Char('\n'));
updateTempProfileProperty(Profile::Environment, newEnvironment);
QStringList newEnvironment;
if (ok) {
if(!text.isEmpty()) {
newEnvironment = text.split(QLatin1Char('\n'));
updateTempProfileProperty(Profile::Environment, newEnvironment);
} else {
// the user could have removed all entries so we return an empty list
updateTempProfileProperty(Profile::Environment, newEnvironment);
}
}
}

Loading…
Cancel
Save