diff options
author | Igor Tarasov <igor.tarasov@mapbox.com> | 2019-09-19 15:18:48 +0300 |
---|---|---|
committer | Igor Tarasov <igor.tarasov@mapbox.com> | 2019-09-19 15:18:48 +0300 |
commit | 93060be3feeb2d4af141b2518a3073da1164f356 (patch) | |
tree | b0252b23482cfb4fd2a2e8a6f2979120696c202b | |
parent | 9dedd12468226381e47469fce2052fde173a6406 (diff) | |
download | qtlocation-mapboxgl-93060be3feeb2d4af141b2518a3073da1164f356.tar.gz |
[android] Style source: keep java's native peer by weak reference.
It prevents native peer to be destroyed by core layer during updates.
-rw-r--r-- | platform/android/src/style/sources/source.cpp | 2 | ||||
-rw-r--r-- | platform/android/src/style/sources/source.hpp | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/platform/android/src/style/sources/source.cpp b/platform/android/src/style/sources/source.cpp index c067c5d1c4..dcbcc483e8 100644 --- a/platform/android/src/style/sources/source.cpp +++ b/platform/android/src/style/sources/source.cpp @@ -100,7 +100,7 @@ namespace android { // Save reference before transferring ownership nonOwnedSource_ = ownedSource_->makeWeakPtr(); // Add peer to core source - ownedSource_->peer = std::unique_ptr<Source>(this); + ownedSource_->peer = weakFactory_.makeWeakPtr(); // Add source to map and release ownership map.getStyle().addSource(std::move(ownedSource_)); diff --git a/platform/android/src/style/sources/source.hpp b/platform/android/src/style/sources/source.hpp index 061529fb9f..3da8840630 100644 --- a/platform/android/src/style/sources/source.hpp +++ b/platform/android/src/style/sources/source.hpp @@ -73,6 +73,7 @@ protected: private: std::unique_ptr<mbgl::style::Source> ownedSource_ { nullptr }; mapbox::base::WeakPtr<mbgl::style::Source> nonOwnedSource_; + mapbox::base::WeakPtrFactory<Source> weakFactory_ {this}; }; } // namespace android |