summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-05-11 10:35:45 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-05-12 11:26:27 -0700
commitafead4e749794e6d0f6b9cb9bd7897face64104a (patch)
tree95e375dbf3c4d4c8ad3cf59c50b176dc532e131e
parent54e26b20e7d64e1c4497ef3c411230fe708851b6 (diff)
downloadqtlocation-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.
-rw-r--r--include/mbgl/style/layer.hpp2
-rw-r--r--include/mbgl/style/source.hpp2
-rw-r--r--src/mbgl/style/layer.cpp2
-rw-r--r--src/mbgl/style/source.cpp2
4 files changed, 4 insertions, 4 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
diff --git a/src/mbgl/style/layer.cpp b/src/mbgl/style/layer.cpp
index fe51dd09ca..142fe313cf 100644
--- a/src/mbgl/style/layer.cpp
+++ b/src/mbgl/style/layer.cpp
@@ -18,7 +18,7 @@ LayerType Layer::getType() const {
return baseImpl->type;
}
-const std::string& Layer::getID() const {
+std::string Layer::getID() const {
return baseImpl->id;
}
diff --git a/src/mbgl/style/source.cpp b/src/mbgl/style/source.cpp
index 4fcebc8377..e7701b8bec 100644
--- a/src/mbgl/style/source.cpp
+++ b/src/mbgl/style/source.cpp
@@ -19,7 +19,7 @@ SourceType Source::getType() const {
return baseImpl->type;
}
-const std::string& Source::getID() const {
+std::string Source::getID() const {
return baseImpl->id;
}