summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-05-10 11:10:23 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-05-10 11:59:02 +0300
commitb41f39d545908dfb9a348aa786620d745d929225 (patch)
treee31ccda473bec9d5a8866afe86fd64fd750cc0e5
parent9fb41a74bcfefefbf79a9bf4090c0e4e90c0e08a (diff)
downloadqtlocation-mapboxgl-b41f39d545908dfb9a348aa786620d745d929225.tar.gz
[core] Make ActorRef methods const
So that the lambdas calling these methods do not have to be mutable.
-rw-r--r--include/mbgl/actor/actor_ref.hpp4
-rw-r--r--platform/default/src/mbgl/map/map_snapshotter.cpp2
-rw-r--r--platform/default/src/mbgl/storage/default_file_source.cpp6
-rw-r--r--platform/default/src/mbgl/storage/online_file_source.cpp2
-rw-r--r--src/mbgl/renderer/image_manager.cpp2
5 files changed, 8 insertions, 8 deletions
diff --git a/include/mbgl/actor/actor_ref.hpp b/include/mbgl/actor/actor_ref.hpp
index 958ee3777c..d700a86d1a 100644
--- a/include/mbgl/actor/actor_ref.hpp
+++ b/include/mbgl/actor/actor_ref.hpp
@@ -29,14 +29,14 @@ public:
}
template <typename Fn, class... Args>
- void invoke(Fn fn, Args&&... args) {
+ void invoke(Fn fn, Args&&... args) const {
if (auto mailbox = weakMailbox.lock()) {
mailbox->push(actor::makeMessage(*object, fn, std::forward<Args>(args)...));
}
}
template <typename Fn, class... Args>
- auto ask(Fn fn, Args&&... args) {
+ auto ask(Fn fn, Args&&... args) const {
// Result type is deduced from the function's return type
using ResultType = typename std::result_of<decltype(fn)(Object, Args...)>::type;
diff --git a/platform/default/src/mbgl/map/map_snapshotter.cpp b/platform/default/src/mbgl/map/map_snapshotter.cpp
index dc3d263261..6e02ac8532 100644
--- a/platform/default/src/mbgl/map/map_snapshotter.cpp
+++ b/platform/default/src/mbgl/map/map_snapshotter.cpp
@@ -81,7 +81,7 @@ MapSnapshotter::Impl::Impl(std::shared_ptr<Scheduler> scheduler_,
}
void MapSnapshotter::Impl::snapshot(ActorRef<MapSnapshotter::Callback> callback) {
- map.renderStill([this, callback = std::move(callback)] (std::exception_ptr error) mutable {
+ map.renderStill([this, callback = std::move(callback)] (std::exception_ptr error) {
// Create lambda that captures the current transform state
// and can be used to translate for geographic to screen
diff --git a/platform/default/src/mbgl/storage/default_file_source.cpp b/platform/default/src/mbgl/storage/default_file_source.cpp
index 08fbbff9a0..2768f9d113 100644
--- a/platform/default/src/mbgl/storage/default_file_source.cpp
+++ b/platform/default/src/mbgl/storage/default_file_source.cpp
@@ -97,7 +97,7 @@ public:
}
void request(AsyncRequest* req, Resource resource, ActorRef<FileSourceRequest> ref) {
- auto callback = [ref] (const Response& res) mutable {
+ auto callback = [ref] (const Response& res) {
ref.invoke(&FileSourceRequest::setResponse, res);
};
@@ -145,7 +145,7 @@ public:
// Get from the online file source
if (resource.hasLoadingMethod(Resource::LoadingMethod::Network)) {
MBGL_TIMING_START(watch);
- tasks[req] = onlineFileSource.request(resource, [=] (Response onlineResponse) mutable {
+ tasks[req] = onlineFileSource.request(resource, [=] (Response onlineResponse) {
this->offlineDatabase->put(resource, onlineResponse);
if (resource.kind == Resource::Kind::Tile) {
// onlineResponse.data will be null if data not modified
@@ -259,7 +259,7 @@ void DefaultFileSource::setResourceCachePath(const std::string& path) {
std::unique_ptr<AsyncRequest> DefaultFileSource::request(const Resource& resource, Callback callback) {
auto req = std::make_unique<FileSourceRequest>(std::move(callback));
- req->onCancel([fs = impl->actor(), req = req.get()] () mutable { fs.invoke(&Impl::cancel, req); });
+ req->onCancel([fs = impl->actor(), req = req.get()] () { fs.invoke(&Impl::cancel, req); });
impl->actor().invoke(&Impl::request, req.get(), resource, req->actor());
diff --git a/platform/default/src/mbgl/storage/online_file_source.cpp b/platform/default/src/mbgl/storage/online_file_source.cpp
index 26c652f28f..4e19d48a15 100644
--- a/platform/default/src/mbgl/storage/online_file_source.cpp
+++ b/platform/default/src/mbgl/storage/online_file_source.cpp
@@ -79,7 +79,7 @@ public:
// Request the ResourceTransform actor a new url and replace the resource url with the
// transformed one before proceeding to schedule the request.
resourceTransform->invoke(&ResourceTransform::transform, request->resource.kind,
- std::move(request->resource.url), [ref = request->actor()](const std::string&& url) mutable {
+ std::move(request->resource.url), [ref = request->actor()](const std::string&& url) {
ref.invoke(&OnlineFileRequest::setTransformedURL, std::move(url));
});
} else {
diff --git a/src/mbgl/renderer/image_manager.cpp b/src/mbgl/renderer/image_manager.cpp
index 860de487e7..936dac75c3 100644
--- a/src/mbgl/renderer/image_manager.cpp
+++ b/src/mbgl/renderer/image_manager.cpp
@@ -183,7 +183,7 @@ void ImageManager::checkMissingAndNotify(ImageRequestor& requestor, const ImageR
auto actorRef = callback->self();
emplaced.first->second.callbacks.emplace(dependency.first, std::move(callback));
- observer->onStyleImageMissing(dependency.first, [actorRef]() mutable {
+ observer->onStyleImageMissing(dependency.first, [actorRef]() {
actorRef.invoke(&Callback::operator());
});