[Bug 257352] Kmail crashed when navigating in the filter list
Tobias Koenig
tokoe at kde.org
Sat Jan 1 17:06:22 GMT 2011
https://bugs.kde.org/show_bug.cgi?id=257352
Tobias Koenig <tokoe at kde.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
--- Comment #1 from Tobias Koenig <tokoe kde org> 2011-01-01 18:06:21 ---
commit fc6a85794370da8bd2322205b5ba16010d6229db
branch master
Author: Tobias Koenig <tokoe at 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 */
--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the Kdepim-bugs
mailing list