summaryrefslogtreecommitdiff
path: root/src/mbgl/style
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 /src/mbgl/style
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.
Diffstat (limited to 'src/mbgl/style')
-rw-r--r--src/mbgl/style/layer.cpp2
-rw-r--r--src/mbgl/style/source.cpp2
2 files changed, 2 insertions, 2 deletions
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;
}