From 15cffcd3a2137ce97a093e114aa4d3e71fd9990b Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Wed, 16 Sep 2015 17:52:49 -0700 Subject: fixes #2350: remove iOS-specific SQLite cache wrapper --- platform/ios/MGLMapView.mm | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'platform/ios/MGLMapView.mm') diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 7056276637..3cee7db4e9 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -28,7 +29,6 @@ #import "NSException+MGLAdditions.h" #import "MGLUserLocationAnnotationView.h" #import "MGLUserLocation_Private.h" -#import "MGLFileCache.h" #import "MGLAccountManager_Private.h" #import "MGLMapboxEvents.h" @@ -112,12 +112,14 @@ mbgl::util::UnitBezier MGLUnitBezierForMediaTimingFunction(CAMediaTimingFunction { mbgl::Map *_mbglMap; MBGLView *_mbglView; + std::shared_ptr _mbglFileCache; mbgl::DefaultFileSource *_mbglFileSource; - BOOL _isWaitingForRedundantReachableNotification; - + NS_MUTABLE_ARRAY_OF(NSURL *) *_bundledStyleURLs; + BOOL _isWaitingForRedundantReachableNotification; BOOL _isTargetingInterfaceBuilder; + CLLocationDegrees _pendingLatitude; CLLocationDegrees _pendingLongitude; } @@ -225,14 +227,24 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) self.backgroundColor = [UIColor clearColor]; self.clipsToBounds = YES; - // setup mbgl map - // + // setup mbgl view const float scaleFactor = [UIScreen instancesRespondToSelector:@selector(nativeScale)] ? [[UIScreen mainScreen] nativeScale] : [[UIScreen mainScreen] scale]; _mbglView = new MBGLView(self, scaleFactor); - _mbglFileSource = new mbgl::DefaultFileSource([MGLFileCache obtainSharedCacheWithObject:self]); - // Start paused + // setup mbgl cache & file source + NSString *fileCachePath = @""; + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); + if ([paths count] != 0) { + NSString *libraryDirectory = [paths objectAtIndex:0]; + fileCachePath = [libraryDirectory stringByAppendingPathComponent:@"cache.db"]; + } + _mbglFileCache = mbgl::SharedSQLiteCache::get([fileCachePath UTF8String]); + _mbglFileSource = new mbgl::DefaultFileSource(_mbglFileCache.get()); + + // setup mbgl map _mbglMap = new mbgl::Map(*_mbglView, *_mbglFileSource, mbgl::MapMode::Continuous); + + // start paused if in IB if (_isTargetingInterfaceBuilder || background) { self.dormant = YES; _mbglMap->pause(); @@ -465,8 +477,6 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) _mbglFileSource = nullptr; } - [MGLFileCache releaseSharedCacheForObject:self]; - if (_mbglView) { delete _mbglView; -- cgit v1.2.1