From 47ff146fb831354b2a45926f2eb041e810e7c2df Mon Sep 17 00:00:00 2001 From: "r.kuznetsov" Date: Fri, 22 Jun 2018 15:09:14 +0300 Subject: [PATCH] Fixed bookmarks catalog downloading --- map/bookmark_catalog.cpp | 17 +++++++++++++---- map/bookmark_manager.cpp | 8 ++++++-- 2 files changed, 19 insertions(+), 6 deletions(-) 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 */); + }); } }); }