summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kitchen <andrew.kitchen@mapbox.com>2017-11-27 21:30:13 -0800
committerAndrew Kitchen <andrew.kitchen@mapbox.com>2017-11-27 21:30:13 -0800
commit6fb3a5f6de3e764bb2873cd4a60204dd01ccc988 (patch)
treee3acc9c991fb1203bff2eb5b94f1d16df65815df
parenta2817ff5ed301f0da5817279ca7184b0c22bdf21 (diff)
downloadqtlocation-mapboxgl-upstream/akitchen-10571.tar.gz
[darwin] Adjusts initializer body to avoid ivar usage before calling superupstream/akitchen-10571
Fixes #10571
-rw-r--r--platform/darwin/src/MGLComputedShapeSource.mm25
1 files changed, 15 insertions, 10 deletions
diff --git a/platform/darwin/src/MGLComputedShapeSource.mm b/platform/darwin/src/MGLComputedShapeSource.mm
index 3176e61a72..0a3c92bb97 100644
--- a/platform/darwin/src/MGLComputedShapeSource.mm
+++ b/platform/darwin/src/MGLComputedShapeSource.mm
@@ -93,32 +93,37 @@
@implementation MGLComputedShapeSource
- (instancetype)initWithIdentifier:(NSString *)identifier options:(NS_DICTIONARY_OF(MGLShapeSourceOption, id) *)options {
- _requestQueue = [[NSOperationQueue alloc] init];
- self.requestQueue.name = [NSString stringWithFormat:@"mgl.MGLComputedShapeSource.%@", identifier];
- self.requestQueue.qualityOfService = NSQualityOfServiceUtility;
- self.requestQueue.maxConcurrentOperationCount = 4;
+ NSOperationQueue *requestQueue = [[NSOperationQueue alloc] init];
+ requestQueue.name = [NSString stringWithFormat:@"mgl.MGLComputedShapeSource.%@", identifier];
+ requestQueue.qualityOfService = NSQualityOfServiceUtility;
+ requestQueue.maxConcurrentOperationCount = 4;
auto sourceOptions = MBGLCustomGeometrySourceOptionsFromDictionary(options);
sourceOptions.fetchTileFunction = ^void(const mbgl::CanonicalTileID& tileID) {
NSOperation *operation = [[MGLComputedShapeSourceFetchOperation alloc] initForSource:self tile:tileID];
- [self.requestQueue addOperation:operation];
+ [requestQueue addOperation:operation];
};
sourceOptions.cancelTileFunction = ^void(const mbgl::CanonicalTileID& tileID) {
- for(MGLComputedShapeSourceFetchOperation *operation in [self.requestQueue operations]) {
- if(operation.x == tileID.x && operation.y == tileID.y && operation.z == tileID.z) {
+ for (MGLComputedShapeSourceFetchOperation *operation in requestQueue.operations) {
+ if (operation.x == tileID.x && operation.y == tileID.y && operation.z == tileID.z) {
[operation cancel];
}
}
};
auto source = std::make_unique<mbgl::style::CustomGeometrySource>(identifier.UTF8String, sourceOptions);
- return self = [super initWithPendingSource:std::move(source)];
+
+ if (self = [super initWithPendingSource:std::move(source)]) {
+ _requestQueue = requestQueue;
+ }
+ return self;
}
- (instancetype)initWithIdentifier:(NSString *)identifier dataSource:(id<MGLComputedShapeSourceDataSource>)dataSource options:(NS_DICTIONARY_OF(MGLShapeSourceOption, id) *)options {
- self = [self initWithIdentifier:identifier options:options];
- [self setDataSource:dataSource];
+ if (self = [self initWithIdentifier:identifier options:options]) {
+ [self setDataSource:dataSource];
+ }
return self;
}