diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-03-08 14:50:49 -0800 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2017-03-09 10:08:09 -0800 |
commit | c047c290566addfc1a923e0d98f0df46f3084b82 (patch) | |
tree | 024d15cd58178c1f52e1b5b8953c7f08fc9210e2 | |
parent | c447614bf4a06943eba321b697475e82d66e7e04 (diff) | |
download | qtlocation-mapboxgl-c047c290566addfc1a923e0d98f0df46f3084b82.tar.gz |
[darwin] Use explicit initialization rather than global static variables for the default RunLoop
When linking Mapbox GL as a static library, the object file (MGLFoundation.o) containing the global static variable initialization was not linked into the resulting binary since it was not referenced. This resulted in the RunLoop not being initialized in the main thread.
Reverts 03a14ff0003e976a4ded70d284bc80adf54bc6c9
-rw-r--r-- | platform/darwin/src/MGLFoundation.mm | 4 | ||||
-rw-r--r-- | platform/darwin/src/MGLFoundation_Private.h | 2 | ||||
-rw-r--r-- | platform/darwin/src/MGLOfflineStorage.mm | 3 |
3 files changed, 7 insertions, 2 deletions
diff --git a/platform/darwin/src/MGLFoundation.mm b/platform/darwin/src/MGLFoundation.mm index 1cc56de298..5cda1dced3 100644 --- a/platform/darwin/src/MGLFoundation.mm +++ b/platform/darwin/src/MGLFoundation.mm @@ -1,4 +1,6 @@ #import "MGLFoundation_Private.h" /// Initializes the run loop shim that lives on the main thread. -mbgl::util::RunLoop mgl_runLoop; +void MGLInitializeRunLoop() { + static mbgl::util::RunLoop runLoop; +} diff --git a/platform/darwin/src/MGLFoundation_Private.h b/platform/darwin/src/MGLFoundation_Private.h index 940bb1df69..f231628756 100644 --- a/platform/darwin/src/MGLFoundation_Private.h +++ b/platform/darwin/src/MGLFoundation_Private.h @@ -2,4 +2,4 @@ #include <mbgl/util/run_loop.hpp> -extern mbgl::util::RunLoop mgl_runLoop; +void MGLInitializeRunLoop(); diff --git a/platform/darwin/src/MGLOfflineStorage.mm b/platform/darwin/src/MGLOfflineStorage.mm index 27a794fcc3..788bb4c159 100644 --- a/platform/darwin/src/MGLOfflineStorage.mm +++ b/platform/darwin/src/MGLOfflineStorage.mm @@ -1,5 +1,6 @@ #import "MGLOfflineStorage_Private.h" +#import "MGLFoundation_Private.h" #import "MGLAccountManager_Private.h" #import "MGLGeometry_Private.h" #import "MGLNetworkConfiguration.h" @@ -156,6 +157,8 @@ NSString * const MGLOfflinePackMaximumCountUserInfoKey = MGLOfflinePackUserInfoK } - (instancetype)init { + MGLInitializeRunLoop(); + if (self = [super init]) { NSURL *cacheURL = [[self class] cacheURLIncludingSubdirectory:YES]; NSString *cachePath = cacheURL.path ?: @""; |