warning message on camera initialization failure added
authorVitalij Tymchyshyn <v.tymchyshyn@samsung.com>
Wed, 20 Mar 2013 06:14:53 +0000 (15:14 +0900)
committerVitalij Tymchyshyn <v.tymchyshyn@samsung.com>
Wed, 20 Mar 2013 06:14:53 +0000 (15:14 +0900)
Change-Id: I9455df1e6cee0e6b02a00211c5b5074f1eaf38cf

project/src/CameraTools.cpp
project/src/ControlManager.cpp
project/src/GLtools.cpp
project/src/QrCodeRecognizerSample.cpp
project/src/Tracker.cpp

index bef47c0..724a17c 100644 (file)
@@ -141,7 +141,14 @@ void
 CameraTools::Restart(void)
 {
     if (__pCamera)
+    {
         __pCamera->StartPreview(null, true);
+    }
+    else
+    {
+        return;
+    }
+
     if (IsFailed(__pCamera->SetFocusMode(Tizen::Media::CAMERA_FOCUS_MODE_CONTINUOUS_AUTO)))
     {
         return;
index 9af300d..fb11210 100644 (file)
@@ -20,7 +20,7 @@
 using namespace Tizen::App;
 using namespace Tizen::Base;
 
-static const String TEMP_VCARD_PATH = L"/opt/media/temp.vcf";
+static const String TEMP_VCARD_PATH = L"/opt/temp.vcf";
 
 ControlManager::ControlManager()
     : __provider("")
index bbba19f..91f4d18 100644 (file)
@@ -89,7 +89,7 @@ GLtools::initEGL()
     eglContext = eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, eglContextList);
     if (EGL_NO_CONTEXT == eglContext || EGL_SUCCESS != eglGetError())
     {
-       return false;
+        return false;
     }
 
     if (EGL_FALSE == eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext) || EGL_SUCCESS != eglGetError())
index 3ccf5e3..511b952 100644 (file)
@@ -61,22 +61,6 @@ QrCodeRecognizer::OnAppInitialized(void)
     // Creates an instance of Popup
     __pPopup = new Tizen::Ui::Controls::Popup();
     __pPopup->Construct(true, Tizen::Graphics::Dimension(570, 250));
-    __pPopup->SetTitleText(L"Exit application?");
-
-    // Creates an instance of Button to close the popup.
-    Button* pYesButton = new Button();
-    pYesButton->Construct(Tizen::Graphics::Rectangle(10, 50, 250, 80), L"Yes");
-    pYesButton->SetActionId(ID_BUTTON_YES);
-    pYesButton->AddActionEventListener(*this);
-
-    Button* pNoButton = new Button();
-    pNoButton->Construct(Tizen::Graphics::Rectangle(270, 50, 250, 80), L"No");
-    pNoButton->SetActionId(ID_BUTTON_NO);
-    pNoButton->AddActionEventListener(*this);
-
-    // Adds the button to the popup
-    __pPopup->AddControl(*pYesButton);
-    __pPopup->AddControl(*pNoButton);
 
     __pPanel = new PanelButton();
     __pPanel->Initialize(this);
@@ -86,16 +70,51 @@ QrCodeRecognizer::OnAppInitialized(void)
     __pForm->Initialize();
     __pForm->AddControl(*__pPanel);
     pAppFrame->AddControl(*__pForm);
-
     GLtools::initGL(__pForm);
+    __pForm->SendUserEvent(TouchForm::REQUEST_ACTIVATE, null);
 
     __pTracker = new Tracker();
-    CameraTools::StartCamera(*__pTracker, Tracker::DESIRED_CAMERA_WIDTH, Tracker::DESIRED_CAMERA_HEIGHT);
-
-    __pTracker->Init(__pForm);
-    CameraTools::Restart();
-
-    __pForm->SendUserEvent(TouchForm::REQUEST_ACTIVATE, null);
+     if(!CameraTools::StartCamera(*__pTracker, Tracker::DESIRED_CAMERA_WIDTH, Tracker::DESIRED_CAMERA_HEIGHT))
+     {
+         delete __pTracker;
+         __pTracker = null;
+
+         __pPopup->SetTitleText(L"No camera");
+
+         // Creates an instance of Button to close the popup.
+         Button* pYesButton = new Button();
+         pYesButton->Construct(Tizen::Graphics::Rectangle(140, 50, 250, 80), L"OK");
+         pYesButton->SetActionId(ID_BUTTON_YES);
+         pYesButton->AddActionEventListener(*this);
+
+         // Adds the button to the popup
+         __pPopup->AddControl(*pYesButton);
+
+         __pPopup->SetShowState(true);
+         __pPopup->Show();
+     }
+     else
+     {
+         __pPopup->SetTitleText(L"Exit application?");
+
+         // Creates an instance of Button to close the popup.
+         Button* pYesButton = new Button();
+         pYesButton->Construct(Tizen::Graphics::Rectangle(10, 50, 250, 80), L"Yes");
+         pYesButton->SetActionId(ID_BUTTON_YES);
+         pYesButton->AddActionEventListener(*this);
+
+         Button* pNoButton = new Button();
+         pNoButton->Construct(Tizen::Graphics::Rectangle(270, 50, 250, 80), L"No");
+         pNoButton->SetActionId(ID_BUTTON_NO);
+         pNoButton->AddActionEventListener(*this);
+
+         // Adds the button to the popup
+         __pPopup->AddControl(*pYesButton);
+         __pPopup->AddControl(*pNoButton);
+
+         __pTracker->Init(__pForm);
+         CameraTools::Restart();
+     }
 
     return true;
 }
@@ -109,11 +128,14 @@ QrCodeRecognizer::OnAppWillTerminate(void)
 bool
 QrCodeRecognizer::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
 {
-    __pTracker->DoRendering(false);
     CameraTools::StopCamera();
     GLtools::destroyGL();
+    if(__pTracker)
+    {
+        __pTracker->DoRendering(false);
+        delete __pTracker;
+    }
 
-    delete __pTracker;
     return true;
 }
 
@@ -167,9 +189,8 @@ QrCodeRecognizer::OnActionPerformed(const Tizen::Ui::Control& source, int action
     break;
     case PanelButton::ID_BUTTON_EXIT:
     {
-//        __pPopup->SetShowState(true);
-        __pTracker->Terminate();
-//        __pPopup->Show();
+        __pPopup->SetShowState(true);
+        __pPopup->Show();
     }
         break;
     case PanelButton::ID_BUTTON_EXECUTE:
@@ -177,9 +198,19 @@ QrCodeRecognizer::OnActionPerformed(const Tizen::Ui::Control& source, int action
         break;
         
     case ID_BUTTON_YES:
-        //Crushing application without this
+    //Crushing application without this
+    if(__pPopup)
+    {
         delete __pPopup;
+    }
+    if(__pTracker)
+    {
         __pTracker->Terminate();
+    }
+    else
+    {
+        Tizen::App::Application::GetInstance()->Terminate();
+    }
         break;
     case ID_BUTTON_NO:
         __pPopup->SetShowState(false);
index 67a8c76..1f41baa 100644 (file)
@@ -22,8 +22,8 @@ Tracker::Tracker()
     : __pQrRecognizer(0)
     , __pRenderer(0)
     , __pRoi(0)
-       , __pLabel(0)
-       , __pForm(0)
+    , __pLabel(0)
+    , __pForm(0)
     , __doRender(true)
     , __terminating(false)
 {
@@ -31,9 +31,18 @@ Tracker::Tracker()
 
 Tracker::~Tracker()
 {
-    delete __pQrRecognizer;
-    delete __pRenderer;
-    delete __pRoi;
+    if(__pQrRecognizer)
+    {
+        delete __pQrRecognizer;
+    }
+    if(__pRenderer)
+    {
+        delete __pRenderer;
+    }
+    if(__pRoi)
+    {
+        delete __pRoi;
+    }
 }
 
 void