[TNEXT-740,TNEXT-741] Fixed crash issue 14/131914/3 accepted/tizen/unified/20170602.154230 submit/tizen/20170601.042236
authorSeonah Moon <seonah1.moon@samsung.com>
Wed, 31 May 2017 07:52:02 +0000 (16:52 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Wed, 31 May 2017 08:54:39 +0000 (17:54 +0900)
- Add NULL checking
- Append custom style to default theme instead of using custom theme

Change-Id: I7be5040eed03acf20c05e5a3a8fd0725f6cfe9c6
Signed-off-by: Seonah Moon <seonah1.moon@samsung.com>
packaging/org.tizen.download-manager.spec
src/download-manager-dateTime.cpp
src/download-manager-view.cpp
src/include/download-manager-view.h

index ba1eba2..326545b 100755 (executable)
@@ -1,7 +1,7 @@
 %define _ux_define tizen2.3
 Name:  org.tizen.download-manager
 Summary:       Application for support of the content download
-Version:       0.3.22
+Version:       0.3.23
 Release:       1
 License:       Flora-1.1
 Group:         misc
index 35e696b..a7fc73e 100755 (executable)
@@ -55,7 +55,7 @@ void DateUtil::deinitLocaleData()
        timeFormat24H = NULL;
 }
 
-int DateUtil::getDiffDays(time_t nowTime,time_t refTime)
+int DateUtil::getDiffDays(time_t nowTime, time_t refTime)
 {
        int diffDays = 0;
        int nowYear = 0;
@@ -65,7 +65,7 @@ int DateUtil::getDiffDays(time_t nowTime,time_t refTime)
 
        struct tm nowDate;
 
-       if(localtime_r(&nowTime,&nowDate)==NULL){
+       if(localtime_r(&nowTime, &nowDate) == NULL){
            DM_LOGE("Error localtime_r");
            return -1;
        }
@@ -75,7 +75,7 @@ int DateUtil::getDiffDays(time_t nowTime,time_t refTime)
 
        struct tm finishedDate;
 
-    if(localtime_r(&refTime,&finishedDate)==NULL){
+    if (localtime_r(&refTime, &finishedDate) == NULL) {
         DM_LOGE("Error localtime_r");
         return -1;
     }
@@ -89,14 +89,14 @@ int DateUtil::getDiffDays(time_t nowTime,time_t refTime)
        DM_LOGV("nowDate[%d/%d/%d]",
                        (nowDate.tm_year + 1900), (nowDate.tm_mon + 1),
                        nowDate.tm_mday);
-       if ((nowYear-refYear)>0 && diffDays < 0) {
+       if ((nowYear-refYear) > 0 && diffDays < 0) {
                int year = nowDate.tm_year;
                diffDays = diffDays + 365;
                /* leap year */
                if ((year%4 == 0 && year%100 != 0) || year%400 == 0)
                        diffDays++;
        }
-       DM_LOGD("diffDays[%d]",diffDays);
+       DM_LOGD("diffDays[%d]", diffDays);
        return diffDays;
 }
 
@@ -105,8 +105,8 @@ i18n_udate_format_h DateUtil::getBestPattern(const char *formatString,
 {
        int ret = I18N_ERROR_NONE;
        i18n_udate_format_h format = NULL;
-       i18n_uchar uchCustomFormat[MAX_SKELETON_BUFFER_LEN] = {0,};
-       i18n_uchar bestPattern[MAX_PATTERN_BUFFER_LEN] = {0,};
+       i18n_uchar uchCustomFormat[MAX_SKELETON_BUFFER_LEN] = { 0, };
+       i18n_uchar bestPattern[MAX_PATTERN_BUFFER_LEN] = { 0, };
        int pattrenLength;
        int bestPatternLength;
 
@@ -138,7 +138,7 @@ void DateUtil::updateLocale()
        const char *locale = NULL;
        i18n_udatepg_h patternGenerator = NULL;
        locale = getenv("LC_TIME");
-       if (strlen(locale) > MAX_STR_LEN) {
+       if (locale && (strlen(locale) > MAX_STR_LEN)) {
                DM_LOGE("Size of locale is greater than MAX STR LEN");
                return;
        }
@@ -192,8 +192,8 @@ void DateUtil::getDateStr(double finishTime, string &outBuf)
        }
        if (format) {
                int formattedLength;
-               i18n_uchar formatted[MAX_BUF_LEN] = {0,};
-               char result[MAX_BUF_LEN] = {0,};
+               i18n_uchar formatted[MAX_BUF_LEN] = { 0, };
+               char result[MAX_BUF_LEN] = { 0, };
                ret = i18n_udate_format_date(format, (finishTime * 1000), formatted,
                                MAX_BUF_LEN, NULL, &formattedLength);
                if (ret != I18N_ERROR_NONE)
index 8b82366..9d0d6dc 100755 (executable)
@@ -54,7 +54,6 @@ DownloadView::DownloadView(void)
        , eoDldList(NULL)
        , eoPopup(NULL)
 #ifdef _TIZEN_2_3_UX
-       , m_theme(NULL)
        , eoMoreMenu(NULL)
        , eoSelectAllLayout(NULL)
        , m_isEditMode(false)
@@ -82,9 +81,7 @@ DownloadView::DownloadView(void)
        DateUtil &inst = DateUtil::getInstance();
        inst.updateLocale();
 #ifdef _TIZEN_2_3_UX
-       m_theme = elm_theme_new();
-       elm_theme_ref_set(m_theme, NULL);
-       elm_theme_extension_add(m_theme, EDJEDIR"/download-manager-view.edj");
+       elm_theme_extension_add(NULL, EDJEDIR"/download-manager-view.edj");
 #endif
 }
 
@@ -92,8 +89,7 @@ DownloadView::~DownloadView()
 {
        DM_LOGD("");
 #ifdef _TIZEN_2_3_UX
-       elm_theme_extension_del(m_theme, EDJEDIR"/download-manager-view.edj");
-       elm_theme_free(m_theme);
+       elm_theme_extension_del(NULL, EDJEDIR"/download-manager-view.edj");
 #endif
 }
 
@@ -278,7 +274,7 @@ void DownloadView::resume()
        // one more check if the vconf value of lock state has not been changed due to some error
        m_activatedLockScreen = false;
        DateUtil &util = DateUtil::getInstance();
-       int diffDays = util.getDiffDays(time(NULL),(time_t)m_viewLastRefreshTime);
+       int diffDays = util.getDiffDays(time(NULL), (time_t)m_viewLastRefreshTime);
        if (diffDays > 0) {
                if (m_viewItemCount > 0)
                        update(diffDays);
@@ -432,7 +428,7 @@ void DownloadView::createNaviBar()
                        eext_naviframe_back_cb, NULL);
        createBox();
        eoNaviBarItem = elm_naviframe_item_push(eoNaviBar,
-               DM_HEADER_DOWNLOAD_MANAGER ,NULL, NULL, eoBox, NULL);
+               DM_HEADER_DOWNLOAD_MANAGERNULL, NULL, eoBox, NULL);
        if (!eoNaviBarItem)
                DM_LOGE("Null Check:eoNaviBarItem");
 #ifdef _TIZEN_2_3_UX
@@ -458,7 +454,7 @@ void DownloadView::showDeletePopup()
 {
        Evas_Object *btn1 = NULL;
        Evas_Object *btn2 = NULL;
-       char buff[MAX_BUF_LEN] = {0,};
+       char buff[MAX_BUF_LEN] = { 0, };
 
        DM_LOGI("");
 
@@ -722,7 +718,7 @@ void DownloadView::realizedCB(void *data, Evas_Object *obj,
 void DownloadView::createList()
 {
        eoDldList = elm_genlist_add(eoLayout);
-       DM_LOGTEST("CREATE:eoDldList[%p]",eoDldList);
+       DM_LOGTEST("CREATE:eoDldList[%p]", eoDldList);
 /* When using ELM_LIST_LIMIT, the window size is broken at the landscape mode */
        evas_object_smart_callback_add(eoDldList, "language,changed", changedGenlistLanguage, NULL);
        evas_object_size_hint_weight_set(eoDldList, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -730,10 +726,7 @@ void DownloadView::createList()
        evas_object_smart_callback_add(eoDldList, "realized", realizedCB, NULL);
        elm_genlist_homogeneous_set(eoDldList, EINA_TRUE);
        elm_genlist_mode_set(eoDldList, ELM_LIST_COMPRESS);
-#ifdef _TIZEN_2_3_UX
-       elm_object_theme_set(eoDldList, m_theme);
-#endif
-       elm_genlist_block_count_set(eoDldList,8);
+       elm_genlist_block_count_set(eoDldList, 8);
        elm_box_pack_end(eoBox, eoDldList);
        evas_object_show(eoDldList);
 }
@@ -778,7 +771,7 @@ void DownloadView::attachViewItem(ViewItem *viewItem)
 
 void DownloadView::detachViewItem(ViewItem *viewItem)
 {
-       DM_LOGI("delete viewItem[%p]",viewItem);
+       DM_LOGI("delete viewItem[%p]", viewItem);
        if (viewItem && viewItem->isGroupTitle() == false) {
                groupTitleType &groupTitleItem = m_groupTitle[viewItem->getItemGroup()];
                m_viewItemCount--;
@@ -804,7 +797,7 @@ void DownloadView::update()
 
        it = elm_genlist_first_item_get(eoDldList);
        while (it) {
-               DM_LOGD("glItem[%p]",it);
+               DM_LOGD("glItem[%p]", it);
                elm_genlist_item_update(it);
                it = elm_genlist_item_next_get(it);
        }
@@ -911,9 +904,9 @@ void DownloadView::update(int diffDays)
                }
                if (yesterdayGroupTitle.viewItem) {
                        itemsCount += yesterdayGroupTitle.subItemsCount;
-                       if (flag)
+                       if (flag) {
                                elm_object_item_del(yesterdayGroupTitle.viewItem->genlistItem());
-                       else {
+                       else {
                                if (olderGroupTitle.viewItem)
                                        elm_object_item_del(olderGroupTitle.viewItem->genlistItem());
                                olderGroupTitle.viewItem = yesterdayGroupTitle.viewItem;
@@ -1011,11 +1004,11 @@ void DownloadView::createGenlistItem(ViewItem *viewItem)
        Elm_Object_Item *glItem = NULL;
        VIEWITEM_GROUP::GROUP group;
        double finishedTime = viewItem->getFinishedTime();
-       if (finishedTime == 0)
+       if (finishedTime == 0) {
                diffDays = 0;
-       else {
+       else {
                DateUtil &inst = DateUtil::getInstance();
-               diffDays = inst.getDiffDays(time(NULL),(time_t)finishedTime);
+               diffDays = inst.getDiffDays(time(NULL), (time_t)finishedTime);
        }
 
        if (diffDays < 1)
@@ -1071,9 +1064,9 @@ void DownloadView::createGenlistItem(ViewItem *viewItem)
                        genlistClickCB,
                        static_cast<const void*>(viewItem));
        }
-       if (!glItem)
+       if (!glItem) {
                DM_LOGE("Fail to add a genlist item");
-       else {
+       else {
                viewItem->setItemGroup(group);
                viewItem->setGenlistItem(glItem);
                groupTitleItem.subItemsCount++;
@@ -1118,9 +1111,9 @@ void DownloadView::showEmptyView()
 #endif
                elm_layout_signal_emit(eoEmptyNoContent, "align.center", "elm");
                if (eoDldList) {
-                       elm_box_unpack(eoBox,eoDldList);
+                       elm_box_unpack(eoBox, eoDldList);
                        /* Detection code */
-                       DM_LOGI("del::eoDldList[%p]",eoDldList);
+                       DM_LOGI("del::eoDldList[%p]", eoDldList);
                        evas_object_del(eoDldList);
                        eoDldList = NULL;
                }
@@ -1497,7 +1490,7 @@ void DownloadView::handleCheckedState()
 
 void DownloadView::showSelectedNotify(int selectedCount)
 {
-       char buff[MAX_BUF_LEN] = {0,};
+       char buff[MAX_BUF_LEN] = { 0, };
 
        DM_LOGD("");
 #ifndef _TIZEN_2_3_UX
@@ -1605,7 +1598,7 @@ void DownloadView::showMemoryFullPopup(string &msg)
 {
        Evas_Object *btn1 = NULL;
        Evas_Object *btn2 = NULL;
-       char buff[MAX_BUF_LEN] = {0,};
+       char buff[MAX_BUF_LEN] = { 0, };
 
        DM_LOGI("");
 
index c107879..212aad7 100755 (executable)
@@ -180,7 +180,6 @@ private:
        Evas_Object *eoDldList;
        Evas_Object *eoPopup;
 #ifdef _TIZEN_2_3_UX
-       Elm_Theme *m_theme;
        Evas_Object *eoMoreMenu;
        Evas_Object *eoSelectAllLayout;
        bool m_isEditMode;