diff --git a/map/bookmark_catalog.cpp b/map/bookmark_catalog.cpp index 6fed36be36..b4c5e7e084 100644 --- a/map/bookmark_catalog.cpp +++ b/map/bookmark_catalog.cpp @@ -89,11 +89,20 @@ void BookmarkCatalog::Download(std::string const & id, std::string const & name, { if (startHandler) startHandler(); - }, [finishHandler = std::move(finishHandler)] (platform::RemoteFile::Result && result, - std::string const & filePath) + }, [this, id, finishHandler = std::move(finishHandler)] (platform::RemoteFile::Result && result, + std::string const & filePath) mutable { - if (finishHandler) - finishHandler(std::move(result), filePath); + GetPlatform().RunTask(Platform::Thread::Gui, [this, id, result = std::move(result), filePath, + finishHandler = std::move(finishHandler)]() mutable + { + if (result.m_status == platform::RemoteFile::Status::Ok) + RegisterDownloadedId(id); + else + m_downloadingIds.erase(id); + + if (finishHandler) + finishHandler(std::move(result), filePath); + }); }); } diff --git a/map/bookmark_manager.cpp b/map/bookmark_manager.cpp index 3a774a0ebe..ecb18ad190 100644 --- a/map/bookmark_manager.cpp +++ b/map/bookmark_manager.cpp @@ -2094,8 +2094,12 @@ void BookmarkManager::ImportDownloadedFromCatalog(std::string const & id, std::s } else { - if (m_onCatalogImportFinished) - m_onCatalogImportFinished(id, false /* successful */); + GetPlatform().RunTask(Platform::Thread::Gui, [this, id] + { + m_bookmarkCatalog.UnregisterDownloadedId(id); + if (m_onCatalogImportFinished) + m_onCatalogImportFinished(id, false /* successful */); + }); } }); }