Fix an issue not to call download_destroy() submit/tizen_2.1/20130514.054137
authorSunwook Bae <sunwook45.bae@samsung.com>
Fri, 10 May 2013 05:09:47 +0000 (14:09 +0900)
committerSunwook Bae <sunwook45.bae@samsung.com>
Fri, 10 May 2013 05:09:47 +0000 (14:09 +0900)
Change-Id: I9f73bf0e873923dc729e8d3a7665b8e1d7ffd419
Signed-off-by: Sunwook Bae <sunwook45.bae@samsung.com>
src/FCnt_DownloadManagerImpl.cpp

index 5e855e4..68d55c5 100644 (file)
@@ -146,7 +146,7 @@ OnStateChanged(int download_id, download_state_e state, void* data)
 
        _DownloadManagerImpl* pDMImpl = (_DownloadManagerImpl*)data;
 
-       if (!data || !pDMImpl->__pEvent)
+       if (!data)
        {
                return;
        }
@@ -160,28 +160,34 @@ OnStateChanged(int download_id, download_state_e state, void* data)
 
                case SLP_STATE_PAUSED:
                {
-                       _DownloadEventArg* pEventArg = new (std::nothrow) _DownloadEventArg();
-                       pEventArg->__id = reqId;
-                       pEventArg->__state = STATE_PAUSED;
+                       if (pDMImpl->__pEvent)
+                       {
+                               _DownloadEventArg* pEventArg = new (std::nothrow) _DownloadEventArg();
+                               pEventArg->__id = reqId;
+                               pEventArg->__state = STATE_PAUSED;
 
-                       pDMImpl->__pEvent->Fire(*pEventArg);
+                               pDMImpl->__pEvent->Fire(*pEventArg);
+                       }
 
                        break;
                }
 
                case SLP_STATE_COMPLETED:
                {
-                       _DownloadEventArg* pEventArg = new (std::nothrow) _DownloadEventArg();
-                       pEventArg->__id = reqId;
-                       pEventArg->__state = STATE_COMPLETED;
+                       if (pDMImpl->__pEvent)
+                       {
+                               _DownloadEventArg* pEventArg = new (std::nothrow) _DownloadEventArg();
+                               pEventArg->__id = reqId;
+                               pEventArg->__state = STATE_COMPLETED;
 
-                       char* path = null;
-                       download_get_downloaded_file_path(download_id, &path);
-                       pEventArg->__path = path;
+                               char* path = null;
+                               download_get_downloaded_file_path(download_id, &path);
+                               pEventArg->__path = path;
 
-                       delete[] path;
+                               delete[] path;
 
-                       pDMImpl->__pEvent->Fire(*pEventArg);
+                               pDMImpl->__pEvent->Fire(*pEventArg);
+                       }
 
                        // Remove the resource from url_download
                        pDMImpl->DestroyResources(reqId);
@@ -191,19 +197,22 @@ OnStateChanged(int download_id, download_state_e state, void* data)
 
                case SLP_STATE_FAILED:
                {
-                       _DownloadEventArg* pEventArg = new (std::nothrow) _DownloadEventArg();
-                       pEventArg->__id = reqId;
-                       pEventArg->__state = STATE_FAILED;
+                       if (pDMImpl->__pEvent)
+                       {
+                               _DownloadEventArg* pEventArg = new (std::nothrow) _DownloadEventArg();
+                               pEventArg->__id = reqId;
+                               pEventArg->__state = STATE_FAILED;
 
-                       download_error_e error;
-                       download_get_error(download_id, &error);
-                       pEventArg->__result = pDMImpl->ConvertToResult(error);
+                               download_error_e error;
+                               download_get_error(download_id, &error);
+                               pEventArg->__result = pDMImpl->ConvertToResult(error);
 
-                       int http_status = 0;
-                       download_get_http_status(download_id, &http_status);
-                       pEventArg->__errorCode = Integer::ToString(http_status);
+                               int http_status = 0;
+                               download_get_http_status(download_id, &http_status);
+                               pEventArg->__errorCode = Integer::ToString(http_status);
 
-                       pDMImpl->__pEvent->Fire(*pEventArg);
+                               pDMImpl->__pEvent->Fire(*pEventArg);
+                       }
 
                        // Comment out due to resume the failed request
                        //pDMImpl->DestroyResources(reqId);
@@ -213,11 +222,14 @@ OnStateChanged(int download_id, download_state_e state, void* data)
 
                case SLP_STATE_CANCELLED:
                {
-                       _DownloadEventArg* pEventArg = new (std::nothrow) _DownloadEventArg();
-                       pEventArg->__id = reqId;
-                       pEventArg->__state = STATE_CANCELLED;
+                       if (pDMImpl->__pEvent)
+                       {
+                               _DownloadEventArg* pEventArg = new (std::nothrow) _DownloadEventArg();
+                               pEventArg->__id = reqId;
+                               pEventArg->__state = STATE_CANCELLED;
 
-                       pDMImpl->__pEvent->Fire(*pEventArg);
+                               pDMImpl->__pEvent->Fire(*pEventArg);
+                       }
 
                        // Remove the resource from url_download
                        pDMImpl->DestroyResources(reqId);