From: Maciej Skrzypkowski Date: Thu, 16 Jun 2016 14:22:47 +0000 (+0200) Subject: Fix for unpresent tab id X-Git-Tag: submit/tizen_mobile/20160620.101318~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=810c0b367cae1564a012f4428bd42a40d143a67c;p=profile%2Fcommon%2Fapps%2Fweb%2Fbrowser.git Fix for unpresent tab id [Issue] http://suprem.sec.samsung.net/jira/browse/TWF-1507 [Problem] There was no check for tab existence in web engine [Solution] added check [Verify] open few tabs, browse, close all, open some again Change-Id: Iecd7dd26af085efa81b872e9c8aeee09a374810f Signed-off-by: Maciej Skrzypkowski --- diff --git a/services/WebEngineService/WebEngineService.cpp b/services/WebEngineService/WebEngineService.cpp index e61dfae7..ae2c25e1 100644 --- a/services/WebEngineService/WebEngineService.cpp +++ b/services/WebEngineService/WebEngineService.cpp @@ -501,6 +501,10 @@ TabId WebEngineService::addTab(const std::string & uri, } Evas_Object* WebEngineService::getTabView(TabId id){ + if (m_tabs.find(id) == m_tabs.end()) { + BROWSER_LOGW("[%s:%d] there is no tab of id %d", __PRETTY_FUNCTION__, __LINE__, id.get()); + return nullptr; + } return m_tabs[id]->getLayout(); } @@ -514,6 +518,11 @@ bool WebEngineService::switchToTab(tizen_browser::basic_webengine::TabId newTabI suspend(); } + if (m_tabs.find(newTabId) == m_tabs.end()) { + BROWSER_LOGW("[%s:%d] there is no tab of id %d", __PRETTY_FUNCTION__, __LINE__, newTabId.get()); + return false; + } + m_currentWebView = m_tabs[newTabId]; m_currentTabId = newTabId; m_mostRecentTab.erase(std::remove(m_mostRecentTab.begin(), m_mostRecentTab.end(), newTabId), m_mostRecentTab.end()); @@ -584,6 +593,10 @@ void WebEngineService::confirmationResult(WebConfirmationPtr c) bool WebEngineService::isPrivateMode(const TabId& id) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (m_tabs.find(id) == m_tabs.end()) { + BROWSER_LOGW("[%s:%d] there is no tab of id %d", __PRETTY_FUNCTION__, __LINE__, id.get()); + return false; + } return m_tabs[id]->isPrivateMode(); } @@ -599,6 +612,10 @@ std::shared_ptr WebEngineService::getSnapsho std::shared_ptr WebEngineService::getSnapshotData(TabId id, int width, int height, bool async, tizen_browser::tools::SnapshotType snapshot_type){ + if (m_tabs.find(id) == m_tabs.end()) { + BROWSER_LOGW("[%s:%d] there is no tab of id %d", __PRETTY_FUNCTION__, __LINE__, id.get()); + return std::shared_ptr(); + } return m_tabs[id]->captureSnapshot(width, height, async, snapshot_type); }