diff --git a/src/SessionManager.cpp b/src/SessionManager.cpp index 028b76f8e..e26fbeff1 100644 --- a/src/SessionManager.cpp +++ b/src/SessionManager.cpp @@ -758,18 +758,23 @@ Profile::Ptr SessionManager::findByShortcut(const QKeySequence& shortcut) void SessionManager::sessionProfileCommandReceived(const QString& text) { - // FIXME: This is inefficient, it creates a new profile instance for - // each set of changes applied. Instead a new profile should be created - // only the first time changes are applied to a session - Session* session = qobject_cast(sender()); Q_ASSERT( session ); ProfileCommandParser parser; QHash changes = parser.parse(text); - Profile::Ptr newProfile = Profile::Ptr(new Profile(_sessionProfiles[session])); - + Profile::Ptr newProfile; + if ( !_sessionRuntimeProfiles.contains(session) ) + { + newProfile = new Profile(_sessionProfiles[session]); + _sessionRuntimeProfiles.insert(session,newProfile); + } + else + { + newProfile = _sessionRuntimeProfiles[session]; + } + QHashIterator iter(changes); while ( iter.hasNext() ) { diff --git a/src/SessionManager.h b/src/SessionManager.h index d89ab909c..4d0adc014 100644 --- a/src/SessionManager.h +++ b/src/SessionManager.h @@ -335,6 +335,7 @@ private: QSet _types; QHash _sessionProfiles; + QHash _sessionRuntimeProfiles; QHash _restoreMapping; struct ShortcutData