[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdepim/akonadi/akonadiconsole
From:       Volker Krause <vkrause () kde ! org>
Date:       2009-09-17 17:28:23
Message-ID: 1253208503.703096.21394.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1024960 by vkrause:

Don't crash when multiple fetch jobs are running.


 M  +8 -9      searchwidget.cpp  
 M  +0 -6      searchwidget.h  


--- trunk/KDE/kdepim/akonadi/akonadiconsole/searchwidget.cpp #1024959:1024960
@@ -81,7 +81,6 @@
 {
   Akonadi::ItemSearchJob *job = new Akonadi::ItemSearchJob( mQueryWidget->toPlainText() );
   connect( job, SIGNAL( result( KJob* ) ), this, SLOT( searchFinished( KJob* ) ) );
-  job->start();
 }
 
 void SearchWidget::searchFinished( KJob *job )
@@ -131,10 +130,9 @@
     return;
 
   const QString uid = index.data( Qt::DisplayRole ).toString();
-  mFetchJob = new Akonadi::ItemFetchJob( Akonadi::Item( uid.toLongLong() ) );
-  mFetchJob->fetchScope().fetchFullPayload();
-  connect( mFetchJob, SIGNAL( result( KJob* ) ), this, SLOT( itemFetched( KJob* ) ) );
-  mFetchJob->start();
+  Akonadi::ItemFetchJob *fetchJob = new Akonadi::ItemFetchJob( Akonadi::Item( uid.toLongLong() ) );
+  fetchJob->fetchScope().fetchFullPayload();
+  connect( fetchJob, SIGNAL( result( KJob* ) ), this, SLOT( itemFetched( KJob* ) ) );
 }
 
 void SearchWidget::itemFetched( KJob *job )
@@ -146,10 +144,11 @@
     return;
   }
 
-  const Akonadi::Item item = mFetchJob->items().first();
-  mItemView->setPlainText( QString::fromUtf8( item.payloadData() ) );
-
-  mFetchJob = 0;
+  Akonadi::ItemFetchJob *fetchJob = qobject_cast<Akonadi::ItemFetchJob*>( job );
+  if ( !fetchJob->items().isEmpty() ) {
+    const Akonadi::Item item = fetchJob->items().first();
+    mItemView->setPlainText( QString::fromUtf8( item.payloadData() ) );
+  }
 }
 
 #include "searchwidget.moc"
--- trunk/KDE/kdepim/akonadi/akonadiconsole/searchwidget.h #1024959:1024960
@@ -24,11 +24,6 @@
 
 #include <QtGui/QWidget>
 
-namespace Akonadi
-{
-class ItemFetchJob;
-}
-
 class KJob;
 class QComboBox;
 class QListView;
@@ -58,7 +53,6 @@
     QListView* mResultView;
     QTextBrowser* mItemView;
     QStringListModel *mResultModel;
-    Akonadi::ItemFetchJob *mFetchJob;
 };
 
 #endif
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic