mpxmusicplayer/commonui/src/mpxalbumartutil.cpp
changeset 2 b70d77332e66
parent 0 ff3acec5bc43
child 4 beaa16f65879
--- a/mpxmusicplayer/commonui/src/mpxalbumartutil.cpp	Thu Jan 07 12:45:53 2010 +0200
+++ b/mpxmusicplayer/commonui/src/mpxalbumartutil.cpp	Mon Jan 18 20:18:06 2010 +0200
@@ -64,6 +64,7 @@
     {
     if (iArtUtil)
         {
+		iArtUtil->CancelRequest();
         delete iArtUtil;
         }
     if(iFilename)
@@ -121,8 +122,16 @@
     {
     MPX_DEBUG1("CMPXAlbumArtUtil::ExtractAlbumArtL(): Entering");
     MPX_DEBUG_THREAD("CMPXAlbumArtUtil::ExtractAlbumArtL()");
-    delete iArtUtil;
-    iArtUtil = NULL;
+    if(iFilename)
+        {  
+        delete iFilename;
+        iFilename = NULL;
+        } 
+    if ( iArtUtil )
+        {
+        delete iArtUtil;
+        iArtUtil = NULL;
+        }
     iArtUtil = CMPXImageUtil::NewL(aObs);
     iDisplayMode = aDisplayMode;
     iImageSize = aSize;
@@ -132,6 +141,7 @@
         {
         if ( aMedia.ValueText( KMPXMediaMusicAlbumArtFileName ).Length() == 0)
             {
+            iReqId = 0;  
             User::Leave( KErrNotFound );
             }
         }
@@ -139,8 +149,6 @@
     if ( aMedia.IsSupported( KMPXMediaGeneralUri ) &&
          aMedia.IsSupported( KMPXMediaMusicAlbumArtFileName ))
         {
-        delete iFilename;
-        iFilename = NULL;
         iFilename = aMedia.ValueText( KMPXMediaMusicAlbumArtFileName ).AllocL();
         if(aSize == iFullScreenImageSize)
             {
@@ -173,6 +181,12 @@
     if ( iArtUtil )
         {
         iArtUtil->CancelRequest();
+        delete iArtUtil;
+        iArtUtil = 0;
+        }
+	if ( iThumbnailManager && iReqId > 0 )
+        {
+         iThumbnailManager->CancelRequest(iReqId);
         }
     iReqId = 0;
     MPX_DEBUG1("CMPXAlbumArtUtil::CancelRequest(): Exiting");
@@ -203,7 +217,7 @@
         TPtrC data = metaCont.Field( aFieldId );
         if(data.Length()==0)
             {
-            iObserver->ExtractAlbumArtCompleted( NULL, KErrNotFound );            
+            User::Leave( KErrNotFound );          
             }
         ret = MPXUser::Alloc8L(data);
 
@@ -258,12 +272,12 @@
                 delete tempBitmap;
                 } 
             }
-        else
+        else if(iReqId == aId)
             {
             iObserver->ExtractAlbumArtCompleted( NULL, KErrNotFound );
             }
         } 	
-    else
+    else if (iArtUtil && iFilename)
         {
         TRAPD( err,
             HBufC8* art( ExtractBinaryMetaDataLC(iFilename->Des(),EMetaDataJpeg ));
@@ -276,6 +290,7 @@
             }  
         } 
 
+    iReqId = 0;
     }
 
 // -----------------------------------------------------------------------------
@@ -302,6 +317,10 @@
             {
             CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC( album, KMPXAlbumMimeType );
             TInt ret = NULL;
+            if(iThumbnailManager && iReqId >0)
+                {
+                iThumbnailManager->CancelRequest( iReqId );
+                }   
             TRAPD(err, iReqId = TInt (iThumbnailManager->GetThumbnailL( *source, (TAny*)ret)));
             if( err != KErrNone)
                 {