diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-03-08 14:50:49 -0800 |
---|---|---|
committer | Jesse Bounds <jesse@rebounds.net> | 2017-03-10 06:48:42 -0800 |
commit | e9cf787779d26333090e66d923ea04ee7b81d857 (patch) | |
tree | a2907b3a36c772548955c1ea2e966f29619255fd | |
parent | 01f126cbc614db79ca139414b193ae6756f556fd (diff) | |
download | qtlocation-mapboxgl-e9cf787779d26333090e66d923ea04ee7b81d857.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 9cb472ce5d..b65932c6e8 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" @@ -170,6 +171,8 @@ NSString * const MGLOfflinePackMaximumCountUserInfoKey = MGLOfflinePackUserInfoK } - (instancetype)init { + MGLInitializeRunLoop(); + if (self = [super init]) { NSURL *cacheURL = [[self class] cacheURLIncludingSubdirectory:YES]; NSString *cachePath = cacheURL.path ?: @""; |