[ios, macos] Changed exception to assert and nil return, since attribution methods can be called via user interaction (without a mechanism to try/catch) (#15764)

This commit is contained in:
Julian Rex
2019-10-05 13:06:28 -04:00
committed by GitHub
parent 5c565a5e51
commit a90e5f6e97
3 changed files with 18 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
#import "MGLImageSource.h"
#import "MGLGeometry_Private.h"
#import "MGLLoggingConfiguration_Private.h"
#import "MGLSource_Private.h"
#import "MGLTileSource_Private.h"
#import "NSURL+MGLAdditions.h"
@@ -99,7 +100,11 @@
}
- (NSString *)attributionHTMLString {
MGLAssertStyleSourceIsValid();
if (!self.rawSource) {
MGLAssert(0, @"Source with identifier `%@` was invalidated after a style change", self.identifier);
return nil;
}
auto attribution = self.rawSource->getAttribution();
return attribution ? @(attribution->c_str()) : nil;
}

View File

@@ -1,5 +1,6 @@
#import "MGLRasterTileSource_Private.h"
#import "MGLLoggingConfiguration_Private.h"
#import "MGLMapView_Private.h"
#import "MGLSource_Private.h"
#import "MGLTileSource_Private.h"
@@ -72,7 +73,11 @@ static const CGFloat MGLRasterTileSourceRetinaTileSize = 512;
}
- (NSString *)attributionHTMLString {
MGLAssertStyleSourceIsValid();
if (!self.rawSource) {
MGLAssert(0, @"Source with identifier `%@` was invalidated after a style change", self.identifier);
return nil;
}
auto attribution = self.rawSource->getAttribution();
return attribution ? @(attribution->c_str()) : nil;
}

View File

@@ -1,6 +1,7 @@
#import "MGLVectorTileSource_Private.h"
#import "MGLFeature_Private.h"
#import "MGLLoggingConfiguration_Private.h"
#import "MGLSource_Private.h"
#import "MGLTileSource_Private.h"
#import "MGLStyle_Private.h"
@@ -44,7 +45,11 @@
}
- (NSString *)attributionHTMLString {
MGLAssertStyleSourceIsValid();
if (!self.rawSource) {
MGLAssert(0, @"Source with identifier `%@` was invalidated after a style change", self.identifier);
return nil;
}
auto attribution = self.rawSource->getAttribution();
return attribution ? @(attribution->c_str()) : nil;
}