Commit bed79d9f authored by Kurt Hindenburg's avatar Kurt Hindenburg

convert QSignalMapper (session finished) to lambda

parent 6cc32028
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
// Qt // Qt
#include <QStringList> #include <QStringList>
#include <QSignalMapper>
#include <QTextCodec> #include <QTextCodec>
// KDE // KDE
...@@ -43,11 +42,6 @@ using namespace Konsole; ...@@ -43,11 +42,6 @@ using namespace Konsole;
SessionManager::SessionManager() SessionManager::SessionManager()
{ {
//map finished() signals from sessions
_sessionMapper = new QSignalMapper(this);
connect(_sessionMapper, static_cast<void (QSignalMapper::*)(QObject *)>(&QSignalMapper::mapped),
this, &Konsole::SessionManager::sessionTerminated);
ProfileManager *profileMananger = ProfileManager::instance(); ProfileManager *profileMananger = ProfileManager::instance();
connect(profileMananger, &Konsole::ProfileManager::profileChanged, this, connect(profileMananger, &Konsole::ProfileManager::profileChanged, this,
&Konsole::SessionManager::profileChanged); &Konsole::SessionManager::profileChanged);
...@@ -107,9 +101,10 @@ Session *SessionManager::createSession(Profile::Ptr profile) ...@@ -107,9 +101,10 @@ Session *SessionManager::createSession(Profile::Ptr profile)
&Konsole::SessionManager::sessionProfileCommandReceived); &Konsole::SessionManager::sessionProfileCommandReceived);
//ask for notification when session dies //ask for notification when session dies
_sessionMapper->setMapping(session, session); connect(session, &Konsole::Session::finished, this,
connect(session, &Konsole::Session::finished, _sessionMapper, [this, session]() {
static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map)); sessionTerminated(session);
});
//add session to active list //add session to active list
_sessions << session; _sessions << session;
...@@ -123,10 +118,8 @@ void SessionManager::profileChanged(Profile::Ptr profile) ...@@ -123,10 +118,8 @@ void SessionManager::profileChanged(Profile::Ptr profile)
applyProfile(profile, true); applyProfile(profile, true);
} }
void SessionManager::sessionTerminated(QObject *sessionObject) void SessionManager::sessionTerminated(Session *session)
{ {
Session *session = qobject_cast<Session *>(sessionObject);
Q_ASSERT(session); Q_ASSERT(session);
_sessions.removeAll(session); _sessions.removeAll(session);
......
...@@ -107,7 +107,7 @@ protected Q_SLOTS: ...@@ -107,7 +107,7 @@ protected Q_SLOTS:
* *
* @param session The Session which has finished executing. * @param session The Session which has finished executing.
*/ */
void sessionTerminated(QObject *sessionObject); void sessionTerminated(Session *session);
private Q_SLOTS: private Q_SLOTS:
void sessionProfileCommandReceived(const QString &text); void sessionProfileCommandReceived(const QString &text);
......
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