diff -r 453dfc402455 -r 0aa8cc770c8a mtpfws/mtpfw/src/cmtpconnection.cpp --- a/mtpfws/mtpfw/src/cmtpconnection.cpp Thu Aug 19 10:44:03 2010 +0300 +++ b/mtpfws/mtpfw/src/cmtpconnection.cpp Tue Aug 31 16:03:15 2010 +0300 @@ -82,17 +82,9 @@ __FLOG(_L8("~CMTPConnection - Entry")); CloseAllSessions(); - // Remove any events not associated - // with a session - TSglQueIter iter(iEventQ); - iter.SetToFirst(); - CMTPEventLink* link = NULL; - - while ((link = iter++) != NULL) - { - delete link; - } - + //remove all events + DequeueAllEvents(); + iSessions.ResetAndDestroy(); if (iTransportConnection != NULL) @@ -667,9 +659,16 @@ DequeueEvent(iEventQ.First()); if (iPendingEventCount > 0) { - // Forward the event to the transport connection layer. - __FLOG(_L8("Sending queued event")); - iTransportConnection->SendEventL(iEventQ.First()->iEvent); + if (NULL != iTransportConnection) + { + // Forward the event to the transport connection layer. + __FLOG(_L8("Sending queued event")); + iTransportConnection->SendEventL(iEventQ.First()->iEvent); + } + else + { + DequeueAllEvents(); + } } __FLOG(_L8("SendEventCompleteL - Exit")); @@ -1046,6 +1045,19 @@ __FLOG(_L8("RemoveEventsForSession - Exit")); } +void CMTPConnection::DequeueAllEvents() + { + TSglQueIter iter(iEventQ); + iter.SetToFirst(); + CMTPEventLink* link = NULL; + + while ((link = iter++) != NULL) + { + delete link; + } + iPendingEventCount = 0; + } + void CMTPConnection::DequeueEvent(CMTPEventLink* aLink) { iEventQ.Remove(*aLink);