diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-09-04 15:28:23 +0300 |
---|---|---|
committer | Julian Rex <julian.rex@mapbox.com> | 2019-09-07 00:15:38 -0400 |
commit | 78ae1917ba448b4cbb8f9ae5cb4da63a81836354 (patch) | |
tree | a3dabc1d9c003886b03b14e6f321e31c9d993c59 | |
parent | 365c38b9ccbe0dab3a2542a504f30d1646a6c325 (diff) | |
download | qtlocation-mapboxgl-78ae1917ba448b4cbb8f9ae5cb4da63a81836354.tar.gz |
[darwin] Use weak pointer to mbgl::Source
-rw-r--r-- | platform/darwin/src/MGLSource.mm | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/platform/darwin/src/MGLSource.mm b/platform/darwin/src/MGLSource.mm index fd54627471..2c673fbb30 100644 --- a/platform/darwin/src/MGLSource.mm +++ b/platform/darwin/src/MGLSource.mm @@ -19,6 +19,7 @@ @implementation MGLSource { std::unique_ptr<mbgl::style::Source> _pendingSource; + mapbox::base::WeakPtr<mbgl::style::Source> _weakSource; } @@ -33,13 +34,18 @@ - (instancetype)initWithRawSource:(mbgl::style::Source *)rawSource mapView:(MGLMapView *)mapView { NSString *identifier = @(rawSource->getID().c_str()); if (self = [self initWithIdentifier:identifier]) { - _rawSource = rawSource; - _rawSource->peer = SourceWrapper { self }; + _weakSource = rawSource->makeWeakPtr(); + rawSource->peer = SourceWrapper { self }; _mapView = mapView; } return self; } +- (mbgl::style::Source *)rawSource +{ + return _weakSource.get(); +} + - (instancetype)initWithPendingSource:(std::unique_ptr<mbgl::style::Source>)pendingSource { if (self = [self initWithRawSource:pendingSource.get() mapView:nil]) { _pendingSource = std::move(pendingSource); |