[android] fix source ownership

This commit is contained in:
Ivo van Dongen
2016-11-10 12:35:49 +01:00
committed by Ivo van Dongen
parent 3a4a27c95f
commit 822b83ae4e
4 changed files with 39 additions and 3 deletions

View File

@@ -1142,9 +1142,13 @@ void nativeAddSource(JNIEnv *env, jni::jobject* obj, jni::jlong nativeMapViewPtr
assert(nativeSourcePtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
Source *source = reinterpret_cast<Source *>(nativeSourcePtr);
nativeMapView->getMap().addSource(source->releaseCoreSource());
Source *source = reinterpret_cast<Source *>(nativeSourcePtr);
try {
source->addToMap(nativeMapView->getMap());
} catch (const std::runtime_error& error) {
jni::ThrowNew(*env, jni::FindClass(*env, "com/mapbox/mapboxsdk/style/sources/CannotAddSourceException"), error.what());
}
}
void nativeRemoveSource(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jni::jstring* id) {