diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-11 10:35:45 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-12 11:26:27 -0700 |
commit | afead4e749794e6d0f6b9cb9bd7897face64104a (patch) | |
tree | 95e375dbf3c4d4c8ad3cf59c50b176dc532e131e /include/mbgl | |
parent | 54e26b20e7d64e1c4497ef3c411230fe708851b6 (diff) | |
download | qtlocation-mapboxgl-afead4e749794e6d0f6b9cb9bd7897face64104a.tar.gz |
[core] Return {Source,Layer}::getID by value
Avoid dangling references in the following sequence:
auto& id = layer->getID();
layer->setMaxZoom(2);
std::cout << id;
The reference would be dangling because mutating the layer allocates a new Immutable impl, and there may be no references to the prior impl, which held the id.
Diffstat (limited to 'include/mbgl')
-rw-r--r-- | include/mbgl/style/layer.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/style/source.hpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/include/mbgl/style/layer.hpp b/include/mbgl/style/layer.hpp index 10176879c5..61706d400b 100644 --- a/include/mbgl/style/layer.hpp +++ b/include/mbgl/style/layer.hpp @@ -92,7 +92,7 @@ public: } LayerType getType() const; - const std::string& getID() const; + std::string getID() const; // Visibility VisibilityType getVisibility() const; diff --git a/include/mbgl/style/source.hpp b/include/mbgl/style/source.hpp index d19dfd4e36..cec9619451 100644 --- a/include/mbgl/style/source.hpp +++ b/include/mbgl/style/source.hpp @@ -56,7 +56,7 @@ public: } SourceType getType() const; - const std::string& getID() const; + std::string getID() const; optional<std::string> getAttribution() const; // Private implementation |