summaryrefslogtreecommitdiff
path: root/platform/android/src/jni.cpp
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-02-21 15:33:59 +0200
committerJesse Bounds <jesse@rebounds.net>2017-02-23 15:07:43 -0800
commitd1f444d63ed8048ec9b95e72ba4c72c3394e8379 (patch)
treed9bd2353f4e2f0db025d6d508dbf6aa13869cf66 /platform/android/src/jni.cpp
parent59820fb63d9970c1e2cda9cf950b819b79b1e7f7 (diff)
downloadqtlocation-mapboxgl-d1f444d63ed8048ec9b95e72ba4c72c3394e8379.tar.gz
[android] remove nonexistent layer or source handling
Diffstat (limited to 'platform/android/src/jni.cpp')
-rwxr-xr-xplatform/android/src/jni.cpp27
1 files changed, 9 insertions, 18 deletions
diff --git a/platform/android/src/jni.cpp b/platform/android/src/jni.cpp
index 3f5f48561b..59602c3299 100755
--- a/platform/android/src/jni.cpp
+++ b/platform/android/src/jni.cpp
@@ -1188,11 +1188,8 @@ void nativeAddLayer(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jlon
void nativeRemoveLayerById(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jni::jstring* id) {
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
- try {
- nativeMapView->getMap().removeLayer(std_string_from_jstring(env, id));
- } catch (const std::runtime_error& error) {
- jni::ThrowNew(*env, jni::FindClass(*env, "com/mapbox/mapboxsdk/style/layers/NoSuchLayerException"), error.what());
- }
+
+ nativeMapView->getMap().removeLayer(std_string_from_jstring(env, id));
}
/**
@@ -1202,11 +1199,10 @@ void nativeRemoveLayer(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, j
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
mbgl::android::Layer *layer = reinterpret_cast<mbgl::android::Layer *>(layerPtr);
- try {
- std::unique_ptr<mbgl::style::Layer> coreLayer = nativeMapView->getMap().removeLayer(layer->get().getID());
+
+ std::unique_ptr<mbgl::style::Layer> coreLayer = nativeMapView->getMap().removeLayer(layer->get().getID());
+ if (coreLayer) {
layer->setLayer(std::move(coreLayer));
- } catch (const std::runtime_error& error) {
- jni::ThrowNew(*env, jni::FindClass(*env, "com/mapbox/mapboxsdk/style/layers/NoSuchLayerException"), error.what());
}
}
@@ -1246,22 +1242,17 @@ void nativeAddSource(JNIEnv *env, jni::jobject* obj, jni::jlong nativeMapViewPtr
void nativeRemoveSourceById(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jni::jstring* id) {
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
- try {
- nativeMapView->getMap().removeSource(std_string_from_jstring(env, id));
- } catch (const std::runtime_error& error) {
- jni::ThrowNew(*env, jni::FindClass(*env, "com/mapbox/mapboxsdk/style/sources/NoSuchSourceException"), error.what());
- }
+ nativeMapView->getMap().removeSource(std_string_from_jstring(env, id));
}
void nativeRemoveSource(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jlong sourcePtr) {
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
mbgl::android::Source *source = reinterpret_cast<mbgl::android::Source *>(sourcePtr);
- try {
- std::unique_ptr<mbgl::style::Source> coreSource = nativeMapView->getMap().removeSource(source->get().getID());
+
+ std::unique_ptr<mbgl::style::Source> coreSource = nativeMapView->getMap().removeSource(source->get().getID());
+ if (coreSource) {
source->setSource(std::move(coreSource));
- } catch (const std::runtime_error& error) {
- jni::ThrowNew(*env, jni::FindClass(*env, "com/mapbox/mapboxsdk/style/sources/NoSuchSourceException"), error.what());
}
}