From 92baf12b456074725cfb74cba601dafd881c3a0a Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 8 Feb 2017 14:35:05 +0100 Subject: Remove disconnected sessions from the cached pool. --- examples/imapresource/imapserverproxy.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'examples/imapresource') diff --git a/examples/imapresource/imapserverproxy.h b/examples/imapresource/imapserverproxy.h index 84343eb..a8d5ac1 100644 --- a/examples/imapresource/imapserverproxy.h +++ b/examples/imapresource/imapserverproxy.h @@ -171,6 +171,11 @@ public: { } + bool operator==(const CachedSession &other) const + { + return mSession && (mSession == other.mSession); + } + bool isConnected() { return (mSession->state() == KIMAP2::Session::State::Authenticated || mSession->state() == KIMAP2::Session::State::Selected) ; @@ -191,6 +196,11 @@ class SessionCache : public QObject { public: void recycleSession(const CachedSession &session) { + QObject::connect(session.mSession, &KIMAP2::Session::stateChanged, this, [this, session](KIMAP2::Session::State newState, KIMAP2::Session::State oldState) { + if (newState == KIMAP2::Session::Disconnected) { + mSessions.removeOne(session); + } + }); mSessions << session; } -- cgit v1.2.3