From afead4e749794e6d0f6b9cb9bd7897face64104a Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 11 May 2017 10:35:45 -0700 Subject: [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. --- include/mbgl/style/layer.hpp | 2 +- include/mbgl/style/source.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') 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 getAttribution() const; // Private implementation -- cgit v1.2.1