From 16de579d7cfc2960793cbcb5e95741f22ab73768 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 22 Dec 2015 15:10:24 -0800 Subject: [core] Rationalize error handling for resource loading * Standardize on std::exception_ptr as the error representation (fixes #2854). * Don't format textual strings at the error source; pass on the constituent data via observer method parameters instead. * Use the null object pattern to simplify observer notification code. * Further refactoring for ResourceLoading tests. --- src/mbgl/text/glyph_store.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'src/mbgl/text/glyph_store.cpp') diff --git a/src/mbgl/text/glyph_store.cpp b/src/mbgl/text/glyph_store.cpp index 047db17b7d..a3d1530e3d 100644 --- a/src/mbgl/text/glyph_store.cpp +++ b/src/mbgl/text/glyph_store.cpp @@ -7,6 +7,9 @@ namespace mbgl { +GlyphStore::GlyphStore() = default; +GlyphStore::~GlyphStore() = default; + void GlyphStore::requestGlyphRange(const std::string& fontStackName, const GlyphRange& range) { assert(util::ThreadContext::currentlyOn(util::ThreadType::Map)); @@ -18,10 +21,8 @@ void GlyphStore::requestGlyphRange(const std::string& fontStackName, const Glyph return; } - auto glyphPBF = std::make_unique(this, fontStackName, range); - glyphPBF->setObserver(this); - - rangeSets.emplace(range, std::move(glyphPBF)); + rangeSets.emplace(range, + std::make_unique(this, fontStackName, range, observer)); } @@ -66,18 +67,6 @@ util::exclusive GlyphStore::getFontStack(const std::string& fontStack return { it->second.get(), std::move(lock) }; } -void GlyphStore::onGlyphPBFLoaded() { - if (observer) { - observer->onGlyphRangeLoaded(); - } -} - -void GlyphStore::onGlyphPBFLoadingFailed(std::exception_ptr error) { - if (observer) { - observer->onGlyphRangeLoadingFailed(error); - } -} - void GlyphStore::setObserver(Observer* observer_) { observer = observer_; } -- cgit v1.2.1