Commit 73dd22e5 authored by Christian Mollekopf's avatar Christian Mollekopf
Browse files

Try to avoid another crash in the imap resource.

This crash might have appeared when:
* KIMAP::LoginJob fails with connectionLost
* SessionPool::onLoginDone calls cancelSessionCreation
* the emit connectDone will hiddenly leave the function and
call IMAPResource::onConnectDone which again calls SessionPool::disconnect
thus potentially deleting all Sessions (although with deleteLater()).
* cancelSessionCreation later calls killSession again with the pointer
that is potentially already deleted using deleteLater from the call to
disconnect.
* The code finally crashes in killSession when calling QObject::disconnect on
the apparently invalid session pointer.

The analysis is based on the backtrace in 322440 (duplicate of 319776).

Note that this analysis makes only sense if the deleteLater was actually
executed for some reason (we somehow entered the eventloop),
and that I never managed to write a testcase reproducing the issue.

Since I'm out of ideas I try anyways, also, code that leaves the function
in the middle of the function due to signals gives me headaches.

BUG: 319776
REVIEW: 114995
parent 2549d74c
......@@ -217,15 +217,13 @@ void SessionPool::cancelSessionCreation( KIMAP::Session *session, int errorCode,
{
m_pendingInitialSession = 0;
QString msg;
if ( m_account ) {
emit connectDone( errorCode,
i18n( "Could not connect to the IMAP-server %1.\n%2",
m_account->server(), errorMessage ) );
msg = i18n( "Could not connect to the IMAP-server %1.\n%2", m_account->server(), errorMessage );
} else {
// Can happen when we lose all ready connections while trying to establish
// a new connection, for example.
emit connectDone( errorCode,
i18n( "Could not connect to the IMAP server.\n%1", errorMessage ) );
msg = i18n( "Could not connect to the IMAP server.\n%1", errorMessage );
}
if ( !m_initialConnectDone ) {
......@@ -239,6 +237,8 @@ void SessionPool::cancelSessionCreation( KIMAP::Session *session, int errorCode,
}
}
}
//Always emit this at the end. This can call SessionPool::disconnect via ImapResource.
emit connectDone( errorCode, msg );
}
void SessionPool::processPendingRequests()
......
Supports Markdown
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