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

List:       kde-commits
Subject:    KDE/kdepimlibs/akonadi
From:       Volker Krause <vkrause () kde ! org>
Date:       2010-07-13 10:16:39
Message-ID: 20100713101639.8E5CDAC867 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1149395 by vkrause:

Prevent double emission of ItemSync::result(), which could cause all kinds
of fancy side-effects. Adapt the unit test to notice this scenario
correctly.


 M  +6 -1      itemsync.cpp  
 M  +2 -1      tests/itemsynctest.cpp  


--- trunk/KDE/kdepimlibs/akonadi/itemsync.cpp #1149394:1149395
@@ -53,7 +53,8 @@
       mStreaming( false ),
       mIncremental( false ),
       mLocalListDone( false ),
-      mDeliveryDone( false )
+      mDeliveryDone( false ),
+      mFinished( false )
     {
       // we want to fetch all data by default
       mFetchScope.fetchFullPayload();
@@ -106,6 +107,7 @@
     bool mIncremental;
     bool mLocalListDone;
     bool mDeliveryDone;
+    bool mFinished;
 };
 
 void ItemSync::Private::createLocalItem( const Item & item )
@@ -124,8 +126,11 @@
   if ( mPendingJobs > 0 || !mDeliveryDone || mTransactionJobs > 0 )
     return;
 
+  if ( !mFinished ) { // prevent double result emission, can happen since \
checkDone() is called from all over the place +    mFinished = true;
   q->emitResult();
 }
+}
 
 ItemSync::ItemSync( const Collection &collection, QObject *parent ) :
     Job( parent ),
--- trunk/KDE/kdepimlibs/akonadi/tests/itemsynctest.cpp #1149394:1149395
@@ -97,10 +97,11 @@
         Item::List l;
         l << origItems[i];
         syncer->setFullSyncItems( l );
-        if ( i < origItems.count() - 1 )
+        if ( i < origItems.count() - 1 ) {
           QTest::qWait( 10 ); // enter the event loop so itemsync actually can do \
something  QCOMPARE( spy.count(), 0 );
       }
+      }
       QTest::qWait( 1000 ); // let it finish its job
       QCOMPARE( spy.count(), 1 );
       KJob *job = spy.at( 0 ).at( 0 ).value<KJob*>();


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

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