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