diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-03 14:25:37 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-13 10:33:18 -0700 |
commit | de6c9b35f35f6ec0950529261b207d716c046beb (patch) | |
tree | f022e3e09b4f8ffbe7646341f91aa76b8081ff62 /platform/darwin/src/MGLStyleLayer_Private.h | |
parent | 98d005792b68d0b299f123c1d31e50c72ba91ba8 (diff) | |
download | qtlocation-mapboxgl-de6c9b35f35f6ec0950529261b207d716c046beb.tar.gz |
[darwin] Simplify MGLStyleLayer initialization and pointer management
Similarly to the previous commit, introduce `-[MGLStyleLayer initWithPendingLayer:]`, allowing the base class to track the owned `_pendingSource` pointer and implement `-addToMapView:` and `-removeFromMapView:` without any casts.
Fixes an issue where `-[MGLStyle layerFromMBGLLayer:]` would wind up creating layers whose `_rawLayer` and `_pendingLayer` held different values.
Diffstat (limited to 'platform/darwin/src/MGLStyleLayer_Private.h')
-rw-r--r-- | platform/darwin/src/MGLStyleLayer_Private.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/platform/darwin/src/MGLStyleLayer_Private.h b/platform/darwin/src/MGLStyleLayer_Private.h index b5d709a7af..d024a0bb13 100644 --- a/platform/darwin/src/MGLStyleLayer_Private.h +++ b/platform/darwin/src/MGLStyleLayer_Private.h @@ -30,6 +30,18 @@ NS_ASSUME_NONNULL_BEGIN @interface MGLStyleLayer (Private) +/** + Initializes and returns a layer with a raw pointer to the backing store, + associated with a style. + */ +- (instancetype)initWithRawLayer:(mbgl::style::Layer *)rawLayer; + +/** + Initializes and returns a layer with an owning pointer to the backing store, + unassociated from a style. + */ +- (instancetype)initWithPendingLayer:(std::unique_ptr<mbgl::style::Layer>)pendingLayer; + @property (nonatomic, readwrite, copy) NSString *identifier; /** @@ -39,7 +51,7 @@ NS_ASSUME_NONNULL_BEGIN pointer value stays even after ownership of the object is transferred via `mbgl::Map addLayer`. */ -@property (nonatomic) mbgl::style::Layer *rawLayer; +@property (nonatomic, readonly) mbgl::style::Layer *rawLayer; /** Adds the mbgl style layer that this object represents to the mbgl map below the |