diff --git a/map/bookmark_manager.cpp b/map/bookmark_manager.cpp index fef0dd94a0..4f7449db1e 100644 --- a/map/bookmark_manager.cpp +++ b/map/bookmark_manager.cpp @@ -55,9 +55,6 @@ void BookmarkManager::ClearBookmarks() void BookmarkManager::LoadBookmarks() { - if (!GetPlatform().IsPro()) - return; - ClearBookmarks(); string const dir = GetPlatform().WritableDir(); @@ -82,13 +79,17 @@ size_t BookmarkManager::AddBookmark(size_t categoryIndex, Bookmark & bm) { bm.SetTimeStamp(time(0)); bm.SetScale(scales::GetScaleLevelD(m_framework.GetNavigator().Screen().GlobalRect().GetLocalRect())); - m_categories[categoryIndex]->AddBookmark(bm); - if (m_categories[categoryIndex]->GetFileName().empty()) - { + + BookmarkCategory * pCat = m_categories[categoryIndex]; + pCat->AddBookmark(bm); + + // Immediately do save category for the new one + // (we need it for the last used category ID). + if (pCat->GetFileName().empty()) m_categories[categoryIndex]->SaveToKMLFile(); - } - m_lastCategoryUrl = m_categories[categoryIndex]->GetFileName(); - return m_categories[categoryIndex]->GetBookmarksCount() - 1; + + m_lastCategoryUrl = pCat->GetFileName(); + return pCat->GetBookmarksCount() - 1; } size_t BookmarkManager::LastEditedBMCategory() diff --git a/map/framework.cpp b/map/framework.cpp index 083a38a941..914f67845e 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -374,10 +374,11 @@ void Framework::LoadBookmarks() { if (!GetPlatform().IsPro()) return; + m_bmManager.LoadBookmarks(); } -size_t Framework::AddBookmark(size_t const & categoryIndex, Bookmark & bm) +size_t Framework::AddBookmark(size_t categoryIndex, Bookmark & bm) { return m_bmManager.AddBookmark(categoryIndex, bm); } @@ -437,7 +438,6 @@ BookmarkAndCategory Framework::GetBookmark(m2::PointD const & pxPoint, double vi { for (int i = 0; i < m_bmManager.AdditionalLayerNumberOfPoi(); ++i) { - m2::PointD const pt = m_bmManager.AdditionalPoiLayerGetBookmark(i)->GetOrg(); if (rect.IsPointInside(pt)) { @@ -454,9 +454,10 @@ BookmarkAndCategory Framework::GetBookmark(m2::PointD const & pxPoint, double vi for (size_t i = 0; i < m_bmManager.GetBmCategoriesCount(); ++i) { - bool currentCategoryIsVisible = m_bmManager.GetBmCategory(i)->IsVisible(); + bool const currentCategoryIsVisible = m_bmManager.GetBmCategory(i)->IsVisible(); if (!currentCategoryIsVisible && returnBookmarkIsVisible) continue; + size_t const count = m_bmManager.GetBmCategory(i)->GetBookmarksCount(); for (size_t j = 0; j < count; ++j) { diff --git a/map/framework.hpp b/map/framework.hpp index 4aa85ef6d9..ed81997519 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -169,11 +169,11 @@ public: /// @name Always returns existing or newly created bookmark category. //@{ - size_t AddBookmark(size_t const & categoryIndex, Bookmark & bm); + size_t AddBookmark(size_t categoryIndex, Bookmark & bm); //@} size_t AddCategory(string const & categoryName); - inline size_t GetBmCategoriesCount() const { return m_bmManager.GetBmCategoriesCount();} + inline size_t GetBmCategoriesCount() const { return m_bmManager.GetBmCategoriesCount(); } /// @returns 0 if category is not found BookmarkCategory * GetBmCategory(size_t index) const;