Summary: | Kmail crashed when navigating in the filter list | ||
---|---|---|---|
Product: | [Applications] kmail2 | Reporter: | sfietkonstantin |
Component: | general | Assignee: | kdepim bugs <kdepim-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | crash | ||
Priority: | NOR | ||
Version: | 2.0.89 | ||
Target Milestone: | --- | ||
Platform: | Mandriva RPMs | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
sfietkonstantin
2010-11-19 21:16:52 UTC
commit fc6a85794370da8bd2322205b5ba16010d6229db branch master Author: Tobias Koenig <tokoe@kde.org> Date: Sat Jan 1 18:06:40 2011 +0100 Do not crash on stale collection Do not crash if the CollectionFetchJob does not return the expected collection because the folder has been removed in the meantime. BUG: 257352 diff --git a/mailcommon/folderrequester.cpp b/mailcommon/folderrequester.cpp index 41b2d63..1836ade 100644 --- a/mailcommon/folderrequester.cpp +++ b/mailcommon/folderrequester.cpp @@ -119,22 +119,36 @@ void FolderRequester::setFolder( const Akonadi::Collection&col ) setCollectionFullPath( mCollection ); mFolderId = QString::number( mCollection.id() ); Akonadi::CollectionFetchJob *job = new Akonadi::CollectionFetchJob( mCollection, Akonadi::CollectionFetchJob::Base, this ); - connect( job, SIGNAL( collectionsReceived( Akonadi::Collection::List ) ), - this, SLOT( slotCollectionsReceived( Akonadi::Collection::List ) ) ); + connect( job, SIGNAL( result( KJob* ) ), + this, SLOT( slotCollectionsReceived( KJob* ) ) ); } else if ( !mMustBeReadWrite ) // the Local Folders root node was selected edit->setText( i18n("Local Folders") ); emit folderChanged( mCollection ); } -void FolderRequester::slotCollectionsReceived( const Akonadi::Collection::List& list ) +void FolderRequester::slotCollectionsReceived( KJob *job ) { - Q_ASSERT( list.size() == 1 ); // we only start jobs on a single collection - const Akonadi::Collection col = list.first(); - // in case this is still the collection we are interested in, update - if ( col.id() == mCollection.id() ) { - mCollection = col; - setCollectionFullPath( col ); + if ( job->error() ) { + mCollection = Akonadi::Collection(); + edit->setText( i18n( "Please select a folder" ) ); + return; + } + + const Akonadi::CollectionFetchJob *fetchJob = qobject_cast<Akonadi::CollectionFetchJob*>( job ); + const Akonadi::Collection::List collections = fetchJob->collections(); + + if ( !collections.isEmpty() ) { + const Akonadi::Collection collection = collections.first(); + // in case this is still the collection we are interested in, update + if ( collection.id() == mCollection.id() ) { + mCollection = collection; + setCollectionFullPath( collection ); + } + } else { + // the requested collection doesn't exists anymore + mCollection = Akonadi::Collection(); + edit->setText( i18n( "Please select a folder" ) ); } } diff --git a/mailcommon/folderrequester.h b/mailcommon/folderrequester.h index 65627d3..3dd42c2 100644 --- a/mailcommon/folderrequester.h +++ b/mailcommon/folderrequester.h @@ -35,8 +35,10 @@ #include <ksharedconfig.h> #include <akonadi/collection.h> +#include <QtGui/QKeyEvent> #include <QtGui/QWidget> -#include <QKeyEvent> + +class KJob; namespace MailCommon { @@ -95,7 +97,7 @@ class Kernel; void slotOpenDialog(); /** Update the information we have about the current folder. */ - void slotCollectionsReceived( const Akonadi::Collection::List& ); + void slotCollectionsReceived( KJob* ); signals: /** Emitted when the folder changed */ |