imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnaildecodetask.cpp
branchRCL_3
changeset 9 dea39715fc05
parent 5 82749d516180
child 15 f0aa341a25bf
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnaildecodetask.cpp	Mon Mar 15 12:41:55 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnaildecodetask.cpp	Wed Mar 31 22:04:49 2010 +0300
@@ -143,28 +143,32 @@
       
     if ( ClientThreadAlive() )
        {
-       TRAP_IGNORE(iServer.AddBitmapToPoolL( iRequestId.iSession, aBitmap, iRequestId ));
-       const TSize bitmapSize = aBitmap->SizeInPixels();
-       iBitmapHandle = aBitmap->Handle();
-       aBitmap = NULL;
-       
-       // Complete message and pass bitmap handle to client
+       // pass bitmap handle to client
        TThumbnailRequestParams& params = iParamsBuf();
        TInt ret = iMessage.Read( 0, iParamsBuf );
        
        if(ret == KErrNone )
            {
-           params.iBitmapHandle = iBitmapHandle;
+           params.iBitmapHandle = aBitmap->Handle();
            ret = iMessage.Write( 0, iParamsBuf );
            }
        
-       Complete( ret );
-       ResetMessageData();
-
-       // Successfully completed the message. The client will send
-       // EReleaseBitmap message later to delete the bitmap from pool.
-       // CThumbnailScaleTask is no longer responsible for that.
-       iBitmapHandle = 0;
+       // add bitmap to pool
+       TRAPD(err, iServer.AddBitmapToPoolL( iRequestId.iSession, aBitmap, iRequestId ) );
+       if (err != KErrNone)
+           {
+           Complete( err );
+           delete aBitmap;
+           aBitmap = NULL;
+           }
+       else
+           {
+           aBitmap = NULL; // Server owns the bitmap now
+       
+           // Complete message
+           Complete( ret );
+           ResetMessageData();
+           }
        }
     else
         {