Commit c45d0769 authored by Francesco Cecconi's avatar Francesco Cecconi

Prevent the opening of two or more "edit profile dialogs" per session.

Fixing the wrong behaviour to open two or more "edit dialog" for
one session/tab with the same profile, and the crash with two or
more "edit dialog", one for different session(tabs) with the same profile.

BUG: 311270
REVIEW: 107640
FIXED-IN: 4.11
parent 48f32443
......@@ -84,6 +84,7 @@ public:
* and make it easy for them to change it.
*/
void selectProfileName();
const Profile::Ptr lookupProfile() const;
public slots:
// reimplemented
......@@ -231,8 +232,6 @@ private:
};
void setupCheckBoxes(BooleanOption* options , const Profile::Ptr profile);
const Profile::Ptr lookupProfile() const;
Ui::EditProfileDialog* _ui;
Profile::Ptr _tempProfile;
Profile::Ptr _profile;
......
......@@ -32,6 +32,10 @@
// Konsole
#include "EditProfileDialog.h"
#include "ProfileManager.h"
#include "Session.h"
#include "TerminalDisplay.h"
#include "SessionManager.h"
#include "SessionController.h"
#include "ui_ManageProfilesDialog.h"
using namespace Konsole;
......@@ -344,10 +348,27 @@ void ManageProfilesDialog::createProfile()
}
void ManageProfilesDialog::editSelected()
{
QList<Profile::Ptr> profiles(selectedProfiles());
foreach (Session* session, SessionManager::instance()->sessions()) {
foreach (TerminalDisplay* terminal, session->views()) {
// Searching for opened profiles
if (terminal->sessionController()->profileDialogPointer() != NULL) {
foreach (const Profile::Ptr & profile, profiles) {
if (profile->name() == terminal->sessionController()->profileDialogPointer()->lookupProfile()->name()
&& terminal->sessionController()->profileDialogPointer()->isVisible()) {
// close opened edit dialog
terminal->sessionController()->profileDialogPointer()->close();
}
}
}
}
}
EditProfileDialog dialog(this);
// the dialog will delete the profile group when it is destroyed
ProfileGroup* group = new ProfileGroup;
foreach(const Profile::Ptr & profile, selectedProfiles()) {
foreach (const Profile::Ptr & profile, profiles) {
group->addProfile(profile);
}
group->updateValues();
......
......@@ -218,6 +218,10 @@ SessionController::~SessionController()
_view->setScreenWindow(0);
_allControllers.remove(this);
if (!_editProfileDialog.isNull()) {
delete _editProfileDialog.data();
}
}
void SessionController::trackOutput(QKeyEvent* event)
{
......@@ -783,12 +787,31 @@ void SessionController::changeCodec(QTextCodec* codec)
_session->setCodec(codec);
}
EditProfileDialog* SessionController::profileDialogPointer()
{
return _editProfileDialog.data();
}
void SessionController::editCurrentProfile()
{
EditProfileDialog* dialog = new EditProfileDialog(QApplication::activeWindow());
// Searching for Edit profile dialog opened with the same profile
foreach (SessionController* session, _allControllers.values()) {
if (session->profileDialogPointer()
&& session->profileDialogPointer()->isVisible()
&& session->profileDialogPointer()->lookupProfile() == SessionManager::instance()->sessionProfile(_session)) {
session->profileDialogPointer()->close();
}
}
// NOTE bug311270: For to prevent the crash, the profile must be reset.
if (!_editProfileDialog.isNull()) {
// exists but not visible
delete _editProfileDialog.data();
}
dialog->setProfile(SessionManager::instance()->sessionProfile(_session));
dialog->show();
_editProfileDialog = new EditProfileDialog(QApplication::activeWindow());
_editProfileDialog.data()->setProfile(SessionManager::instance()->sessionProfile(_session));
_editProfileDialog.data()->show();
}
void SessionController::renameSession()
......
......@@ -62,6 +62,7 @@ class IncrementalSearchBar;
class ProfileList;
class UrlFilter;
class RegExpFilter;
class EditProfileDialog;
// SaveHistoryTask
class TerminalCharacterDecoder;
......@@ -144,6 +145,8 @@ public:
*/
void setShowMenuAction(QAction* action);
EditProfileDialog* profileDialogPointer();
// reimplemented
virtual KUrl url() const;
virtual QString currentDir() const;
......@@ -340,6 +343,7 @@ private:
QStringList _bookmarkValidProgramsToClear;
bool _isSearchBarEnabled;
QWeakPointer<EditProfileDialog> _editProfileDialog;
QString _searchText;
};
......
......@@ -3105,6 +3105,11 @@ void TerminalDisplay::setSessionController(SessionController* controller)
_sessionController = controller;
}
SessionController* TerminalDisplay::sessionController()
{
return _sessionController;
}
AutoScrollHandler::AutoScrollHandler(QWidget* parent)
: QObject(parent)
, _timerId(0)
......
......@@ -51,7 +51,6 @@ namespace Konsole
class FilterChain;
class TerminalImageFilterChain;
class SessionController;
/**
* A widget which displays output from a terminal emulation and sends input keypresses and mouse activity
* to the terminal.
......@@ -217,6 +216,7 @@ public:
uint lineSpacing() const;
void setSessionController(SessionController* controller);
SessionController* sessionController();
/**
* Sets the shape of the keyboard cursor. This is the cursor drawn
......
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