summaryrefslogtreecommitdiff
path: root/src/mbgl/text/glyph_store.cpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-12-22 15:10:24 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-12-23 12:50:42 -0800
commit16de579d7cfc2960793cbcb5e95741f22ab73768 (patch)
treeb4c3b7651f605e3d3dd61b469f61036bd2c4dcc3 /src/mbgl/text/glyph_store.cpp
parent7bd4745cf10c504a4899a37016e87bce45e51472 (diff)
downloadqtlocation-mapboxgl-16de579d7cfc2960793cbcb5e95741f22ab73768.tar.gz
[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.
Diffstat (limited to 'src/mbgl/text/glyph_store.cpp')
-rw-r--r--src/mbgl/text/glyph_store.cpp21
1 files changed, 5 insertions, 16 deletions
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<GlyphPBF>(this, fontStackName, range);
- glyphPBF->setObserver(this);
-
- rangeSets.emplace(range, std::move(glyphPBF));
+ rangeSets.emplace(range,
+ std::make_unique<GlyphPBF>(this, fontStackName, range, observer));
}
@@ -66,18 +67,6 @@ util::exclusive<FontStack> 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_;
}