TT-158 Fixed 'Clear History' bug 73/47473/7 accepted/tizen/tv/20150904.064311 submit/tizen_tv/20150903.235433
authort.dakowicz <t.dakowicz@samsung.com>
Thu, 3 Sep 2015 14:25:39 +0000 (16:25 +0200)
committerTomasz Dakowicz <t.dakowicz@samsung.com>
Thu, 3 Sep 2015 15:01:32 +0000 (08:01 -0700)
[Issue#] https://bugs.tizen.org/jira/browse/TT-158
[Problem] Browser's crash after clicking on 'clear history'
          button
[Cause] 'm_historyUI' object was not freed after closing the HistoryUI,
        which caused multiple sending of the clearHistory signal
[Solution] Provided proper object management and prevented multiple
           creation of the 'm_historyUI'.
           In addition, there is a problem with displaying NoHistoryLabel
           from the HistoryUI - currently, it is not available from there
[Verify] Do some browsing -> MoreMenu -> History Manager -> Clear
         Check if this action causes browser's crash

Change-Id: I8be4b31c67b901d241d0bafdd621b72d5ea4c5f4

services/HistoryUI/HistoryUI.cpp
services/HistoryUI/HistoryUI.h
services/SimpleUI/SimpleUI.cpp

index a2dc558..f9c3a12 100644 (file)
@@ -185,7 +185,6 @@ void HistoryUI::addHistoryItem(std::shared_ptr<services::HistoryItem> hi)
     itemData->item = hi;
     itemData->historyUI = std::shared_ptr<tizen_browser::base_ui::HistoryUI>(this);
     _history_item_data.push_back(itemData);
-    setEmptyGengrid(false);
 }
 
 void HistoryUI::addHistoryItems(std::shared_ptr<services::HistoryItemVector> items)
@@ -253,33 +252,12 @@ void HistoryUI::removeHistoryItem(const std::string& uri)
     Elm_Object_Item* historyView = m_map_history_views.at(uri);
     elm_object_item_del(historyView);
     m_map_history_views.erase(uri);
-
-    setEmptyGengrid(0 == m_map_history_views.size());
-}
-
-Evas_Object* HistoryUI::createNoHistoryLabel()
-{
-    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
-    Evas_Object *label = elm_label_add(m_parent);
-    elm_object_text_set(label, "No favorite websites.");
-    evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-    evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
-    return label;
-}
-
-void HistoryUI::setEmptyGengrid(bool setEmpty)
-{
-    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
-    Evas_Object *obj = (setEmpty ? createNoHistoryLabel() : nullptr);
-    elm_object_part_content_set(m_gengrid, "elm.swallow.empty", obj);
 }
 
 void HistoryUI::hide()
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
-    evas_object_hide(elm_layout_content_get(m_history_layout, "m_genListToday"));
-    evas_object_hide(elm_layout_content_get(m_history_layout, "m_gengrid"));
-    evas_object_hide(elm_layout_content_get(m_history_layout, "m_ActionBar"));
+    evas_object_hide(elm_layout_content_get(m_history_layout, "action_bar_history"));
     evas_object_hide(m_history_layout);
 }
 
@@ -291,7 +269,6 @@ void HistoryUI::clearItems()
     elm_gengrid_clear(m_gengrid);
     m_map_history_views.clear();
     _history_item_data.clear();
-    setEmptyGengrid(true);
 }
 
 void HistoryUI::_history_item_clicked_cb(void *data, Evas_Object *obj, void *event_info)
index 1eb4a24..83bd6f6 100644 (file)
@@ -60,8 +60,6 @@ private:
     static void _close_clicked_cb(void *data, Evas_Object *obj, void *event_info);
     static void _history_item_clicked_cb(void *data, Evas_Object *obj, void *event_info);
 
-    void setEmptyGengrid(bool setEmpty);
-
     Evas_Object *m_history_layout;
     Evas_Object *m_actionBar;
     Evas_Object *m_genListToday;
@@ -71,7 +69,6 @@ private:
     Elm_Gengrid_Item_Class * m_item_class;
     std::map<std::string,Elm_Object_Item*> m_map_history_views;
     std::string m_edjFilePath;
-    Evas_Object *createNoHistoryLabel();
 };
 
 }
index 91bcecb..de0e0d6 100644 (file)
@@ -313,7 +313,6 @@ int SimpleUI::exec(const std::string& _url)
         m_mainUI->mostVisitedClicked.connect(boost::bind(&SimpleUI::onMostVisitedClicked, this,_1));
         m_mainUI->bookmarkClicked.connect(boost::bind(&SimpleUI::onBookmarkButtonClicked, this,_1));
         m_mainUI->bookmarkManagerClicked.connect(boost::bind(&SimpleUI::onBookmarkManagerButtonClicked, this,_1));
-
        }
 
        if (url.empty()) {
@@ -621,8 +620,7 @@ void SimpleUI::onClearHistoryClicked(const std::string&)
 {
     BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
     m_historyService->clearAllHistory();
-    m_mainUI->clearHistoryGenlist();
-    m_mainUI->showHistory();
+    m_historyUI.reset();
 }
 
 void SimpleUI::onMostVisitedClicked(const std::string&)
@@ -1111,21 +1109,24 @@ void SimpleUI::showMainUI()
 void SimpleUI::showHistoryUI(const std::string& str)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
-    m_historyUI =
-    std::dynamic_pointer_cast<tizen_browser::base_ui::HistoryUI,tizen_browser::core::AbstractService>
-        (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.historyui"));
-    M_ASSERT(m_historyUI);
-    m_historyUI->clearHistoryClicked.connect(boost::bind(&SimpleUI::onClearHistoryClicked, this,_1));
-    m_historyUI->closeHistoryUIClicked.connect(boost::bind(&SimpleUI::closeHistoryUI, this,_1));
-    m_historyUI->historyItemClicked.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this,_1));
-    m_historyUI->addHistoryItems(getHistory());
-    m_historyUI->show(m_window.get());
+    if(!m_historyUI)
+    {
+        m_historyUI =
+        std::dynamic_pointer_cast<tizen_browser::base_ui::HistoryUI,tizen_browser::core::AbstractService>
+            (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.historyui"));
+        M_ASSERT(m_historyUI);
+        m_historyUI->clearHistoryClicked.connect(boost::bind(&SimpleUI::onClearHistoryClicked, this,_1));
+        m_historyUI->closeHistoryUIClicked.connect(boost::bind(&SimpleUI::closeHistoryUI, this,_1));
+        m_historyUI->historyItemClicked.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this,_1));
+        m_historyUI->addHistoryItems(getHistory());
+        m_historyUI->show(m_window.get());
+    }
 }
 
 void SimpleUI::closeHistoryUI(const std::string& str)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
-    m_historyUI = nullptr;
+    m_historyUI.reset();
 }
 
 void SimpleUI::showSettingsUI(const std::string& str)