summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2018-09-04 09:36:57 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2018-09-04 09:36:57 -0700
commit40023a6840f8c4f88e1f49e244f0fb105338320f (patch)
tree601706ac6e604b6bd66e83317c6a714f62d7f516
parente4bcd1abed607117b21fa518782a694873d0686b (diff)
downloadqtlocation-mapboxgl-upstream/fix-12712.tar.gz
[android] Retain a shared thread pool referenceupstream/fix-12712
Otherwise it may be prematurely deleted.
-rw-r--r--platform/android/src/style/sources/geojson_source.cpp10
-rw-r--r--platform/android/src/style/sources/geojson_source.hpp1
2 files changed, 7 insertions, 4 deletions
diff --git a/platform/android/src/style/sources/geojson_source.cpp b/platform/android/src/style/sources/geojson_source.cpp
index e526231763..9d6ca704eb 100644
--- a/platform/android/src/style/sources/geojson_source.cpp
+++ b/platform/android/src/style/sources/geojson_source.cpp
@@ -45,15 +45,17 @@ namespace android {
GeoJSONSource::GeoJSONSource(jni::JNIEnv& env, jni::String sourceId, jni::Object<> options)
: Source(env, std::make_unique<mbgl::style::GeoJSONSource>(
jni::Make<std::string>(env, sourceId),
- convertGeoJSONOptions(env, options))
- ), converter(std::make_unique<Actor<FeatureConverter>>(*sharedThreadPool())) {
+ convertGeoJSONOptions(env, options)))
+ , threadPool(sharedThreadPool())
+ , converter(std::make_unique<Actor<FeatureConverter>>(*threadPool)) {
}
GeoJSONSource::GeoJSONSource(jni::JNIEnv& env,
mbgl::style::Source& coreSource,
AndroidRendererFrontend& frontend)
- : Source(env, coreSource, createJavaPeer(env), frontend)
- , converter(std::make_unique<Actor<FeatureConverter>>(*sharedThreadPool())) {
+ : Source(env, coreSource, createJavaPeer(env), frontend)
+ , threadPool(sharedThreadPool())
+ , converter(std::make_unique<Actor<FeatureConverter>>(*threadPool)) {
}
GeoJSONSource::~GeoJSONSource() = default;
diff --git a/platform/android/src/style/sources/geojson_source.hpp b/platform/android/src/style/sources/geojson_source.hpp
index b9c360c67c..24ea3c73f8 100644
--- a/platform/android/src/style/sources/geojson_source.hpp
+++ b/platform/android/src/style/sources/geojson_source.hpp
@@ -62,6 +62,7 @@ private:
jni::Object<Source> createJavaPeer(jni::JNIEnv&);
std::unique_ptr<Update> awaitingUpdate;
std::unique_ptr<Update> update;
+ std::shared_ptr<ThreadPool> threadPool;
std::unique_ptr<Actor<FeatureConverter>> converter;
template <class JNIType>