Commit 94505d94 authored by Ahmad Samir's avatar Ahmad Samir Committed by Kurt Hindenburg
Browse files

Make the "Edit Current Profile" dialog modal

This should prevent opening two instance of the EditProfileDialog in the
same process, i.e. if "run all konsole windows in a single process" option is:
- Enabled, then opening the dialog will block user interaction with all
  other konsole windows (including tabs).
- Disabled, then open the dialog will block user interactin with all
  other tabs in the same window

This simplifies the code since it checked if such a dialog was open
somewhere else to prevent crashes.
parent 61a7947a
......@@ -120,7 +120,6 @@ SessionController::SessionController(Session* sessionParam, TerminalDisplay* vie
, _showMenuAction(nullptr)
, _bookmarkValidProgramsToClear(QStringList())
, _isSearchBarEnabled(false)
, _editProfileDialog(nullptr)
, _searchBar(viewParam->searchBar())
, _monitorProcessFinish(false)
, _escapedUrlFilter(nullptr)
......@@ -248,9 +247,6 @@ SessionController::~SessionController()
{
_allControllers.remove(this);
if (!_editProfileDialog.isNull()) {
_editProfileDialog->deleteLater();
}
if(factory() != nullptr) {
factory()->removeClient(this);
}
......@@ -900,29 +896,8 @@ void SessionController::changeCodec(QTextCodec* codec)
session()->setCodec(codec);
}
EditProfileDialog* SessionController::profileDialogPointer()
{
return _editProfileDialog.data();
}
void SessionController::editCurrentProfile()
{
// Searching for Edit profile dialog opened with the same profile
for (SessionController *controller : qAsConst(_allControllers)) {
if ( (controller->profileDialogPointer() != nullptr)
&& controller->profileDialogPointer()->isVisible()
&& (controller->profileDialogPointer()->lookupProfile()
== SessionManager::instance()->sessionProfile(session())) ) {
controller->profileDialogPointer()->close();
}
}
// NOTE bug311270: For to prevent the crash, the profile must be reset.
if (!_editProfileDialog.isNull()) {
// exists but not visible
_editProfileDialog->deleteLater();
}
auto profile = SessionManager::instance()->sessionProfile(session());
// Don't edit the Fallback profile, instead create a new one
if (profile->isFallback()) {
......@@ -935,15 +910,17 @@ void SessionController::editCurrentProfile()
SessionManager::instance()->setSessionProfile(session(), profile);
}
_editProfileDialog = new EditProfileDialog(QApplication::activeWindow());
_editProfileDialog->setProfile(profile);
auto *dialog = new EditProfileDialog(QApplication::activeWindow());
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->setModal(true);
dialog->setProfile(profile);
connect(_editProfileDialog, &QDialog::accepted, this, [profile]() {
connect(dialog, &QDialog::accepted, this, [profile]() {
ProfileManager::instance()->addProfile(profile);
ProfileManager::instance()->changeProfile(profile, profile->setProperties());
});
_editProfileDialog->show();
dialog->show();
}
void SessionController::renameSession()
......
......@@ -123,8 +123,6 @@ public:
*/
void setShowMenuAction(QAction *action);
EditProfileDialog *profileDialogPointer();
// reimplemented
QUrl url() const override;
QString currentDir() const override;
......@@ -350,7 +348,6 @@ private:
QStringList _bookmarkValidProgramsToClear;
bool _isSearchBarEnabled;
QPointer<EditProfileDialog> _editProfileDialog;
QString _searchText;
QPointer<IncrementalSearchBar> _searchBar;
......
Markdown is supported
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