scrsaver/scrsaverplugins/SlideshowPlugin/src/SlideshowPlugin.cpp
branchRCL_3
changeset 31 8f536f98e1f8
parent 27 fc25e03508fd
--- a/scrsaver/scrsaverplugins/SlideshowPlugin/src/SlideshowPlugin.cpp	Wed Sep 15 12:13:53 2010 +0300
+++ b/scrsaver/scrsaverplugins/SlideshowPlugin/src/SlideshowPlugin.cpp	Wed Oct 13 14:33:00 2010 +0300
@@ -134,19 +134,8 @@
     delete iDrmHelper;
     delete iModel;
 
-    // Close and delete mds query
-    if ( iQuery )
-        {
-        iQuery->Cancel();
-        delete iQuery;
-        iQuery = NULL;
-        }
-
-	if ( iMdESession )
-        {
-        delete iMdESession;
-        iMdESession = NULL;
-        }
+    // First model, then engine, otherwise bad things happen
+    delete iMdESession;
     
     // Logging done
     SSPLOGGER_DELETE;
@@ -800,11 +789,16 @@
 void CSlideshowPlugin::LoadRandomSlidesL()
     {
     SSPLOGGER_ENTERFN("LoadRandomSlidesL()");
+
     // Start by getting rid of possibly loaded slides
     iModel->DeleteAll();
-    // connect to MDS, load data or not
+
+    // connect to MDS
     ConnectToMDSSessionL();
 
+    // Wait for query of MDS to complete before continuing
+    WaitForMDS();
+
     SSPLOGGER_LEAVEFN("LoadRandomSlidesL()");
     }
 
@@ -946,8 +940,6 @@
     if (!iMdESession)
         {
         iMdESession = CMdESession::NewL( *this );
-        // Wait for query of MDS to complete before continuing
-        WaitForMDS();
         }
     }
 
@@ -1012,9 +1004,9 @@
     CMdEObjectDef& imageObjDef = defaultNamespaceDef.GetObjectDefL( MdeConstants::Image::KImageObject );
 
     // query objects with object definition "Image"
-    iQuery = iMdESession->NewObjectQueryL( defaultNamespaceDef, imageObjDef, this );
+    CMdEObjectQuery* query = iMdESession->NewObjectQueryL( defaultNamespaceDef, imageObjDef, this );
 
-    iQuery->FindL( KDefaultRandomLoadingNumber );
+    query->FindL( KDefaultRandomLoadingNumber );
     }
 
 // -----------------------------------------------------------------------------