javauis/mmapi_akn/baseline/src/cmmacamerawindow.cpp
branchRCL_3
changeset 17 0fd27995241b
parent 14 04becd199f91
--- a/javauis/mmapi_akn/baseline/src/cmmacamerawindow.cpp	Fri Apr 30 10:40:48 2010 +0300
+++ b/javauis/mmapi_akn/baseline/src/cmmacamerawindow.cpp	Tue May 11 16:07:20 2010 +0300
@@ -206,7 +206,6 @@
         // Stop and start ViewFinder to update position
         ResetViewFinder();
     }
-
 }
 
 
@@ -311,8 +310,6 @@
                 *this, CMMACameraWindow::EResetViewFinder);
         }
     }
-
-
 }
 
 
@@ -616,10 +613,6 @@
         {
             iUICamera->StopViewFinder();
         }
-        if (iDirectAccess->IsActive())
-        {
-            iDirectAccess->Cancel();
-        }
 
         iViewFinderVisible = EFalse;
     }
@@ -717,11 +710,12 @@
     }
     else
     {
-        DEBUG_INT(
-            "MMA::CMMACameraWindow::StartViewFinder()  - \
-StartViewFinderDirectL error=%d", vfError);
+        DEBUG_INT("MMA::CMMACameraWindow::StartViewFinder()  - \
+            StartViewFinderDirectL error=%d", vfError);
 
-        TRAP_IGNORE(DrawViewFinderErrorL(vfError, drawRect));
+        TRAPD(error, DrawViewFinderErrorL(vfError, drawRect));
+        DEBUG_INT("MMA::CMMACameraWindow::StartViewFinder, \
+            DrawViewFinderErrorL error = %d", error);
     }
 
     DEBUG(" > StartViewFinder");
@@ -738,8 +732,18 @@
     const TInt /*aError*/,
     const TRect& aDrawRect)
 {
+    if (!iDirectAccess)
+    {
+        if (!iWs || !iScreenDevice || !iWindow) return;
 
-    ASSERT(iDirectAccess);
+        DEBUG("MMA::CMMACameraWindow::DrawViewFinderErrorL - \
+            Instantiating CDirectScreenAccess");
+        iDirectAccess = CDirectScreenAccess::NewL(*iWs,
+                                     *iScreenDevice,
+                                     *iWindow,
+                                     *this);
+    }
+
     TInt dcError = KErrNone;
     if (!iDirectAccess->IsActive())
     {
@@ -831,9 +835,12 @@
         delete iUICamera;
         iUICamera = NULL;
         iCameraPowerOn = EFalse;
-        iDirectAccess->Cancel();
-        delete iDirectAccess;
-        iDirectAccess = NULL;
+        if (iDirectAccess)
+        {
+            iDirectAccess->Cancel();
+            delete iDirectAccess;
+            iDirectAccess = NULL;
+        }
         delete iErrorIconBitmap;
         iErrorIconBitmap = NULL;
         delete iErrorIconMaskBitmap;
@@ -882,15 +889,6 @@
     CWsScreenDevice &aScreenDevice,
     RWindowBase &aWindow)
 {
-    TRAPD(error, iDirectAccess = CDirectScreenAccess::NewL(aWs,
-                                 aScreenDevice,
-                                 aWindow,
-                                 *this));
-    DEBUG_INT("MMA::CMMACameraWindow::MdcDSAResourcesCallback, error = %d", error);
-    if (KErrNone != error)
-    {
-        return;
-    }
     this->UIStartViewFinder(aWs, aScreenDevice, aWindow);
 }