diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index f7051cae8ad7f23cecba5aac7f11ddf13c101611..9033363b29745a9b803dcd8ea2e23c45dc418a56 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -368,7 +368,8 @@ SessionManager::SessionManager(QObject *parent) : QObject(parent), m_core(Core::ICore::instance()), m_file(new SessionFile), - m_sessionNode(new Internal::SessionNodeImpl(this)) + m_sessionNode(new Internal::SessionNodeImpl(this)), + m_currentEditor(0) { // Create qtcreator dir if it doesn't yet exist QString configDir = QFileInfo(m_core->settings()->fileName()).path(); @@ -394,7 +395,7 @@ SessionManager::SessionManager(QObject *parent) connect(ProjectExplorerPlugin::instance(), SIGNAL(currentProjectChanged(ProjectExplorer::Project *)), this, SLOT(updateWindowTitle())); connect(m_core->editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)), - this, SLOT(updateWindowTitle())); + this, SLOT(handleCurrentEditorChange(Core::IEditor*))); } SessionManager::~SessionManager() @@ -876,6 +877,18 @@ Core::IFile *SessionManager::file() const return m_file; } +void SessionManager::handleCurrentEditorChange(Core::IEditor *editor) +{ + if (editor != m_currentEditor) { + if (m_currentEditor) + disconnect(m_currentEditor, SIGNAL(changed()), this, SLOT(updateWindowTitle())); + if (editor) + connect(editor, SIGNAL(changed()), this, SLOT(updateWindowTitle())); + m_currentEditor = editor; + } + updateWindowTitle(); +} + void SessionManager::updateWindowTitle() { QString windowTitle = tr("Qt Creator"); diff --git a/src/plugins/projectexplorer/session.h b/src/plugins/projectexplorer/session.h index eb9f027b368e6d8b9a501b40a074a21d4b2d158b..f158a04e3a8b77a261b2914bd2c7b3732e1d713d 100644 --- a/src/plugins/projectexplorer/session.h +++ b/src/plugins/projectexplorer/session.h @@ -37,6 +37,7 @@ #include <QtCore/QList> #include <QtCore/QString> #include <QtCore/QStringList> +#include <QtCore/QPointer> QT_BEGIN_NAMESPACE class QAbstractItemModel; @@ -169,6 +170,7 @@ private slots: void saveActiveMode(Core::IMode *mode); void clearProjectFileCache(); void setEditorCodec(Core::IEditor *editor, const QString &fileName); + void handleCurrentEditorChange(Core::IEditor *editor); void updateWindowTitle(); private: @@ -188,6 +190,7 @@ private: Internal::SessionFile *m_file; Internal::SessionNodeImpl *m_sessionNode; + QPointer<Core::IEditor> m_currentEditor; QString m_displayName; QString m_sessionName;