summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkevin <kevin.li@mapbox.com>2020-03-23 10:27:36 +0800
committerkevin <kevin.li@mapbox.com>2020-03-24 11:46:55 +0800
commitc7bf0a6b641c979179855e1a498af43585e8b51f (patch)
tree49beb3eac8378f926275fbebb1a770ed76797816
parente4d959933182ee2f9c7eb18fe34e683276431aba (diff)
downloadqtlocation-mapboxgl-c7bf0a6b641c979179855e1a498af43585e8b51f.tar.gz
Fix review comments
-rw-r--r--platform/android/src/snapshotter/map_snapshotter.cpp21
-rw-r--r--platform/android/src/snapshotter/map_snapshotter.hpp2
2 files changed, 11 insertions, 12 deletions
diff --git a/platform/android/src/snapshotter/map_snapshotter.cpp b/platform/android/src/snapshotter/map_snapshotter.cpp
index f3884efb30..adf654cb10 100644
--- a/platform/android/src/snapshotter/map_snapshotter.cpp
+++ b/platform/android/src/snapshotter/map_snapshotter.cpp
@@ -70,7 +70,6 @@ MapSnapshotter::~MapSnapshotter() {
weakScheduler->schedule([ptr = snapshotter.release()]() mutable {
if (ptr) {
delete ptr;
- ptr = nullptr;
}
});
}
@@ -191,10 +190,10 @@ void MapSnapshotter::onStyleImageMissing(const std::string& imageName) {
void MapSnapshotter::addLayerAt(JNIEnv& env, jlong nativeLayerPtr, jni::jint index) {
assert(nativeLayerPtr != 0);
- auto layers = snapshotter->getStyle().getLayers();
+ const auto layers = snapshotter->getStyle().getLayers();
auto* layer = reinterpret_cast<Layer*>(nativeLayerPtr);
// Check index
- int numLayers = layers.size() - 1;
+ const int numLayers = layers.size() - 1;
if (index > numLayers || index < 0) {
Log::Error(Event::JNI, "Index out of range: %i", index);
jni::ThrowNew(env,
@@ -229,27 +228,27 @@ void MapSnapshotter::addLayerAbove(JNIEnv& env, jlong nativeLayerPtr, const jni:
auto* layer = reinterpret_cast<Layer*>(nativeLayerPtr);
// Find the sibling
- auto layers = snapshotter->getStyle().getLayers();
+ const auto layers = snapshotter->getStyle().getLayers();
auto siblingId = jni::Make<std::string>(env, above);
size_t index = 0;
- for (auto l : layers) {
+ for (auto* l : layers) {
+ ++index;
if (l->getID() == siblingId) {
break;
}
- index++;
}
// Check if we found a sibling to place before
mbgl::optional<std::string> before;
- if (index + 1 > layers.size()) {
+ if (index > layers.size()) {
// Not found
jni::ThrowNew(env,
jni::FindClass(env, "com/mapbox/mapboxsdk/style/layers/CannotAddLayerException"),
std::string("Could not find layer: ").append(siblingId).c_str());
- } else if (index + 1 < layers.size()) {
+ } else if (index < layers.size()) {
// Place before the sibling
- before = {layers.at(index + 1)->getID()};
+ before = {layers.at(index)->getID()};
}
// Add the layer
@@ -309,13 +308,13 @@ void MapSnapshotter::registerNative(jni::JNIEnv& env) {
const jni::String&>,
"nativeInitialize",
"finalize",
- METHOD(&MapSnapshotter::setStyleUrl, "nativeSetStyleUrl"),
+ METHOD(&MapSnapshotter::setStyleUrl, "setStyleUrl"),
METHOD(&MapSnapshotter::addLayerAt, "nativeAddLayerAt"),
METHOD(&MapSnapshotter::addLayerBelow, "nativeAddLayerBelow"),
METHOD(&MapSnapshotter::addLayerAbove, "nativeAddLayerAbove"),
METHOD(&MapSnapshotter::addSource, "nativeAddSource"),
METHOD(&MapSnapshotter::addImages, "nativeAddImages"),
- METHOD(&MapSnapshotter::setStyleJson, "nativeSetStyleJson"),
+ METHOD(&MapSnapshotter::setStyleJson, "setStyleJson"),
METHOD(&MapSnapshotter::setSize, "setSize"),
METHOD(&MapSnapshotter::setCameraPosition, "setCameraPosition"),
METHOD(&MapSnapshotter::setRegion, "setRegion"),
diff --git a/platform/android/src/snapshotter/map_snapshotter.hpp b/platform/android/src/snapshotter/map_snapshotter.hpp
index 00b0f1c72e..c7a9ce14ad 100644
--- a/platform/android/src/snapshotter/map_snapshotter.hpp
+++ b/platform/android/src/snapshotter/map_snapshotter.hpp
@@ -37,7 +37,7 @@ public:
jni::jboolean showLogo,
const jni::String& localIdeographFontFamily);
- virtual ~MapSnapshotter();
+ virtual ~MapSnapshotter() override;
void setStyleUrl(JNIEnv&, const jni::String& styleURL);