diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2020-02-25 22:25:10 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2020-02-26 22:31:59 +0200 |
commit | aad13f6a3f998dc5b699b9e09484ca63bb5be6f1 (patch) | |
tree | c2de65ea2cb23bb5c1740f55a92d85eaae8f2e83 /platform | |
parent | 1399040087f9d0b6f2a836fc5e6468c938ebf99b (diff) | |
download | qtlocation-mapboxgl-aad13f6a3f998dc5b699b9e09484ca63bb5be6f1.tar.gz |
[core] FileSourceManager::getFileSource() returns PassRefPtr
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/src/file_source.cpp | 8 | ||||
-rw-r--r-- | platform/android/src/offline/offline_manager.cpp | 5 | ||||
-rw-r--r-- | platform/android/src/offline/offline_region.cpp | 5 | ||||
-rw-r--r-- | platform/darwin/src/MGLOfflineStorage.mm | 4 | ||||
-rw-r--r-- | platform/glfw/main.cpp | 8 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl.cpp | 3 |
6 files changed, 18 insertions, 15 deletions
diff --git a/platform/android/src/file_source.cpp b/platform/android/src/file_source.cpp index 8bbe9acbd2..5a46bffd3e 100644 --- a/platform/android/src/file_source.cpp +++ b/platform/android/src/file_source.cpp @@ -41,10 +41,10 @@ FileSource::FileSource(jni::JNIEnv& _env, const jni::String& accessToken, const // TODO: Split Android FileSource API to smaller interfaces resourceLoader = mbgl::FileSourceManager::get()->getFileSource(mbgl::FileSourceType::ResourceLoader, resourceOptions); - databaseSource = std::static_pointer_cast<mbgl::DatabaseFileSource>( - mbgl::FileSourceManager::get()->getFileSource(mbgl::FileSourceType::Database, resourceOptions)); - onlineSource = std::static_pointer_cast<mbgl::OnlineFileSource>( - mbgl::FileSourceManager::get()->getFileSource(mbgl::FileSourceType::Network, resourceOptions)); + databaseSource = std::static_pointer_cast<mbgl::DatabaseFileSource>(std::shared_ptr<mbgl::FileSource>( + mbgl::FileSourceManager::get()->getFileSource(mbgl::FileSourceType::Database, resourceOptions))); + onlineSource = std::static_pointer_cast<mbgl::OnlineFileSource>(std::shared_ptr<mbgl::FileSource>( + mbgl::FileSourceManager::get()->getFileSource(mbgl::FileSourceType::Network, resourceOptions))); } FileSource::~FileSource() { diff --git a/platform/android/src/offline/offline_manager.cpp b/platform/android/src/offline/offline_manager.cpp index 98f2b88a7f..51d2f70fe0 100644 --- a/platform/android/src/offline/offline_manager.cpp +++ b/platform/android/src/offline/offline_manager.cpp @@ -25,8 +25,9 @@ void handleException(std::exception_ptr exception, // OfflineManager // OfflineManager::OfflineManager(jni::JNIEnv& env, const jni::Object<FileSource>& jFileSource) - : fileSource(std::static_pointer_cast<mbgl::DatabaseFileSource>(mbgl::FileSourceManager::get()->getFileSource( - mbgl::FileSourceType::Database, FileSource::getSharedResourceOptions(env, jFileSource)))) { + : fileSource(std::static_pointer_cast<mbgl::DatabaseFileSource>( + std::shared_ptr<mbgl::FileSource>(mbgl::FileSourceManager::get()->getFileSource( + mbgl::FileSourceType::Database, FileSource::getSharedResourceOptions(env, jFileSource))))) { if (!fileSource) { ThrowNew(env, jni::FindClass(env, "java/lang/IllegalStateException"), "Offline functionality is disabled."); } diff --git a/platform/android/src/offline/offline_region.cpp b/platform/android/src/offline/offline_region.cpp index 4ee835bab3..de7abef624 100644 --- a/platform/android/src/offline/offline_region.cpp +++ b/platform/android/src/offline/offline_region.cpp @@ -16,8 +16,9 @@ namespace android { OfflineRegion::OfflineRegion(jni::JNIEnv& env, jni::jlong offlineRegionPtr, const jni::Object<FileSource>& jFileSource) : region(reinterpret_cast<mbgl::OfflineRegion*>(offlineRegionPtr)), - fileSource(std::static_pointer_cast<mbgl::DatabaseFileSource>(mbgl::FileSourceManager::get()->getFileSource( - mbgl::FileSourceType::Database, FileSource::getSharedResourceOptions(env, jFileSource)))) { + fileSource(std::static_pointer_cast<mbgl::DatabaseFileSource>( + std::shared_ptr<mbgl::FileSource>(mbgl::FileSourceManager::get()->getFileSource( + mbgl::FileSourceType::Database, FileSource::getSharedResourceOptions(env, jFileSource))))) { if (!fileSource) { ThrowNew(env, jni::FindClass(env, "java/lang/IllegalStateException"), "Offline functionality is disabled."); } diff --git a/platform/darwin/src/MGLOfflineStorage.mm b/platform/darwin/src/MGLOfflineStorage.mm index abf67d330e..275a58f418 100644 --- a/platform/darwin/src/MGLOfflineStorage.mm +++ b/platform/darwin/src/MGLOfflineStorage.mm @@ -233,8 +233,8 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio options.withCachePath(_mbglCachePath) .withAssetPath([NSBundle mainBundle].resourceURL.path.UTF8String); _mbglFileSource = mbgl::FileSourceManager::get()->getFileSource(mbgl::FileSourceType::ResourceLoader, options); - _mbglOnlineFileSource = std::static_pointer_cast<mbgl::OnlineFileSource>(mbgl::FileSourceManager::get()->getFileSource(mbgl::FileSourceType::Network, options)); - _mbglDatabaseFileSource = std::static_pointer_cast<mbgl::DatabaseFileSource>(mbgl::FileSourceManager::get()->getFileSource(mbgl::FileSourceType::Database, options)); + _mbglOnlineFileSource = std::static_pointer_cast<mbgl::OnlineFileSource>(std::shared_ptr<mbgl::FileSource>(mbgl::FileSourceManager::get()->getFileSource(mbgl::FileSourceType::Network, options))); + _mbglDatabaseFileSource = std::static_pointer_cast<mbgl::DatabaseFileSource>(std::shared_ptr<mbgl::FileSource>(mbgl::FileSourceManager::get()->getFileSource(mbgl::FileSourceType::Database, options))); // Observe for changes to the API base URL (and find out the current one). [[MGLAccountManager sharedManager] addObserver:self diff --git a/platform/glfw/main.cpp b/platform/glfw/main.cpp index ded8ee3e1f..784e002a65 100644 --- a/platform/glfw/main.cpp +++ b/platform/glfw/main.cpp @@ -107,7 +107,7 @@ int main(int argc, char *argv[]) { mbgl::ResourceOptions resourceOptions; resourceOptions.withCachePath(cacheDB).withAccessToken(token); - auto onlineFileSource = + std::shared_ptr<mbgl::FileSource> onlineFileSource = mbgl::FileSourceManager::get()->getFileSource(mbgl::FileSourceType::Network, resourceOptions); if (!settings.online) { if (onlineFileSource) { @@ -165,7 +165,7 @@ int main(int argc, char *argv[]) { }); // Resource loader controls top-level request processing and can resume / pause all managed sources simultaneously. - auto resourceLoader = + std::shared_ptr<mbgl::FileSource> resourceLoader = mbgl::FileSourceManager::get()->getFileSource(mbgl::FileSourceType::ResourceLoader, resourceOptions); view->setPauseResumeCallback([resourceLoader]() { static bool isPaused = false; @@ -180,8 +180,8 @@ int main(int argc, char *argv[]) { }); // Database file source. - auto databaseFileSource = std::static_pointer_cast<mbgl::DatabaseFileSource>( - mbgl::FileSourceManager::get()->getFileSource(mbgl::FileSourceType::Database, resourceOptions)); + auto databaseFileSource = std::static_pointer_cast<mbgl::DatabaseFileSource>(std::shared_ptr<mbgl::FileSource>( + mbgl::FileSourceManager::get()->getFileSource(mbgl::FileSourceType::Database, resourceOptions))); view->setResetCacheCallback([databaseFileSource]() { databaseFileSource->resetDatabase([](std::exception_ptr ex) { if (ex) { diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index 65ecf1ce61..5b47174b77 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -1751,7 +1751,8 @@ QMapboxGLPrivate::QMapboxGLPrivate(QMapboxGL *q, const QMapboxGLSettings &settin mbgl::ResourceTransform::FinishedCallback onFinished) { actorRef.invoke(&mbgl::ResourceTransform::TransformCallback::operator(), kind, url, std::move(onFinished)); }}; - auto fs = mbgl::FileSourceManager::get()->getFileSource(mbgl::FileSourceType::Network, resourceOptions); + std::shared_ptr<mbgl::FileSource> fs = + mbgl::FileSourceManager::get()->getFileSource(mbgl::FileSourceType::Network, resourceOptions); std::static_pointer_cast<mbgl::OnlineFileSource>(fs)->setResourceTransform(std::move(transform)); } |