photosgallery/viewframework/commandhandlers/commoncommandhandlers/src/glxcommandhandlernewmedia.cpp
branchRCL_3
changeset 64 34937ec34dac
parent 60 5b3385a43d68
child 75 01504893d9cb
--- a/photosgallery/viewframework/commandhandlers/commoncommandhandlers/src/glxcommandhandlernewmedia.cpp	Wed Sep 01 12:33:26 2010 +0100
+++ b/photosgallery/viewframework/commandhandlers/commoncommandhandlers/src/glxcommandhandlernewmedia.cpp	Tue Sep 14 21:19:17 2010 +0300
@@ -11,17 +11,13 @@
 *
 * Contributors:
 *
-* Description:    Delete command handler
+* Description:    New media command handler
 *
 */
 
 
 
 
-/**
- * @internal reviewed 06/06/2007 by Dave Schofield
- */
-
 #include "glxcommandhandlernewmedia.h"
 
 #include <AknUtils.h>
@@ -297,14 +293,18 @@
             KGlxMediaCollectionPluginSpecificDefaultMediaTitle);
     rootList->AddContextL(attributeContext, KGlxFetchContextPriorityBlocking);
 
-    TGlxFetchContextRemover contextRemover(attributeContext, *rootList);
-    // put to cleanupstack as cleanupstack is emptied before stack objects
-    // are deleted
-    CleanupClosePushL(contextRemover);
-    User::LeaveIfError(GlxAttributeRetriever::RetrieveL(*attributeContext,
-            *rootList, ETrue));
-    // context off the list
-    CleanupStack::PopAndDestroy(&contextRemover);
+    // Media list must not have been deleted when the destructor of 
+    // TGlxContextRemover is called while going out-of-scope.
+        {
+        TGlxFetchContextRemover contextRemover(attributeContext, *rootList);
+        // put to cleanupstack as cleanupstack is emptied before stack objects
+        // are deleted
+        CleanupClosePushL(contextRemover);
+        User::LeaveIfError(GlxAttributeRetriever::RetrieveL(
+                *attributeContext, *rootList, ETrue));
+        // context off the list
+        CleanupStack::PopAndDestroy(&contextRemover);
+        } // Limiting scope of contextRemover
 
     TInt index = rootList->Index(KGlxIdSpaceIdRoot, aCollectionId);