diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2020-02-11 12:12:57 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2020-02-11 14:34:46 +0200 |
commit | 3bd2d0e4d7d52dc88d30081922e1708f0d5a4bcf (patch) | |
tree | f2b143fc74c48283e8ad43005c4da8050bb88042 /src/mbgl/style | |
parent | f38330a9f58ca3b2664168c7830811055870bc42 (diff) | |
download | qtlocation-mapboxgl-3bd2d0e4d7d52dc88d30081922e1708f0d5a4bcf.tar.gz |
style::Style::getImage() returns optional<style::Image>
Diffstat (limited to 'src/mbgl/style')
-rw-r--r-- | src/mbgl/style/style.cpp | 9 | ||||
-rw-r--r-- | src/mbgl/style/style_impl.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/style/style_impl.hpp | 2 |
3 files changed, 8 insertions, 9 deletions
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index 1814ba8adb..902cc1687c 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -60,11 +60,10 @@ const Light* Style::getLight() const { return impl->getLight(); } -const PremultipliedImage* Style::getImage(const std::string& name) const { - if (auto* image = impl->getImage(name)) { - return &(image->image); - } - return nullptr; +optional<Image> Style::getImage(const std::string& name) const { + auto image = impl->getImage(name); + if (!image) return nullopt; + return style::Image(std::move(*image)); } void Style::addImage(std::unique_ptr<Image> image) { diff --git a/src/mbgl/style/style_impl.cpp b/src/mbgl/style/style_impl.cpp index 2d4376073d..59cb57aca6 100644 --- a/src/mbgl/style/style_impl.cpp +++ b/src/mbgl/style/style_impl.cpp @@ -301,10 +301,10 @@ void Style::Impl::removeImage(const std::string& id) { images = std::move(newImages); } -const style::Image::Impl* Style::Impl::getImage(const std::string& id) const { +optional<Immutable<style::Image::Impl>> Style::Impl::getImage(const std::string& id) const { auto found = std::find_if(images->begin(), images->end(), [&id](const auto& image) { return image->id == id; }); - if (found == images->end()) return nullptr; - return found->get(); + if (found == images->end()) return nullopt; + return *found; } void Style::Impl::setObserver(style::Observer* observer_) { diff --git a/src/mbgl/style/style_impl.hpp b/src/mbgl/style/style_impl.hpp index f7dc7af293..c16b82e90b 100644 --- a/src/mbgl/style/style_impl.hpp +++ b/src/mbgl/style/style_impl.hpp @@ -78,7 +78,7 @@ public: void setLight(std::unique_ptr<Light>); Light* getLight() const; - const style::Image::Impl* getImage(const std::string&) const; + optional<Immutable<style::Image::Impl>> getImage(const std::string&) const; void addImage(std::unique_ptr<style::Image>); void removeImage(const std::string&); |