MCPcopy Create free account
hub / github.com/comaps/comaps / NotifyAboutFinishAsyncLoading

Method NotifyAboutFinishAsyncLoading

libs/map/bookmark_manager.cpp:2172–2252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2170}
2171
2172void BookmarkManager::NotifyAboutFinishAsyncLoading(KMLDataCollectionPtr && collection)
2173{
2174 if (m_needTeardown)
2175 return;
2176
2177 GetPlatform().RunTask(Platform::Thread::Gui, [this, collection]()
2178 {
2179 if (!collection->empty())
2180 {
2181 CreateCategories(std::move(*collection), true /* autoSave */);
2182 }
2183 else if (!m_loadBookmarksFinished)
2184 {
2185 CheckAndResetLastIds();
2186 CheckAndCreateDefaultCategory();
2187 }
2188
2189 m_loadBookmarksFinished = true;
2190
2191 // Validate custom order: remove entries for deleted categories, append new ones.
2192 {
2193 auto & catOrder = m_metadata.m_categoryOrder;
2194 if (!catOrder.empty())
2195 {
2196 bool changed = false;
2197 // Normalize legacy full-path entries to basenames and deduplicate.
2198 std::vector<std::string> normalized;
2199 for (auto const & fn : catOrder)
2200 {
2201 auto const basename = base::FileNameFromFullPath(fn);
2202 if (!basename.empty() && std::find(normalized.begin(), normalized.end(), basename) == normalized.end())
2203 normalized.push_back(basename);
2204 }
2205 if (normalized != catOrder)
2206 {
2207 catOrder = std::move(normalized);
2208 changed = true;
2209 }
2210 // Remove entries for deleted categories.
2211 auto const eraseEnd = std::remove_if(catOrder.begin(), catOrder.end(), [this](auto const & fn) {
2212 return GetCategoryByFileName(fn) == kml::kInvalidMarkGroupId;
2213 });
2214 if (eraseEnd != catOrder.end())
2215 {
2216 catOrder.erase(eraseEnd, catOrder.end());
2217 changed = true;
2218 }
2219 // Append new categories that are not yet in the order.
2220 for (auto const & [id, cat] : m_categories)
2221 {
2222 auto const fn = cat->GetFileName();
2223 auto const basename = base::FileNameFromFullPath(fn);
2224 if (!fn.empty() && std::find(catOrder.begin(), catOrder.end(), basename) == catOrder.end())
2225 {
2226 catOrder.push_back(basename);
2227 changed = true;
2228 }
2229 }

Callers

nothing calls this directly

Calls 11

FileNameFromFullPathFunction · 0.85
findFunction · 0.85
ASSERTFunction · 0.85
RunTaskMethod · 0.80
frontMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
eraseMethod · 0.45
GetFileNameMethod · 0.45

Tested by

no test coverage detected