diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/darwin/src/run_loop.cpp | 2 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 8 | ||||
-rw-r--r-- | platform/macos/src/MGLMapView.mm | 8 |
3 files changed, 17 insertions, 1 deletions
diff --git a/platform/darwin/src/run_loop.cpp b/platform/darwin/src/run_loop.cpp index 6e9a1c50b0..63bd8d2f53 100644 --- a/platform/darwin/src/run_loop.cpp +++ b/platform/darwin/src/run_loop.cpp @@ -8,7 +8,6 @@ namespace mbgl { namespace util { static ThreadLocal<RunLoop>& current = *new ThreadLocal<RunLoop>; -static RunLoop mainRunLoop; class RunLoop::Impl { public: @@ -22,6 +21,7 @@ RunLoop* RunLoop::Get() { RunLoop::RunLoop(Type) : impl(std::make_unique<Impl>()) { + assert(!current.get()); current.set(this); impl->async = std::make_unique<AsyncTask>(std::bind(&RunLoop::process, this)); } diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 9067efc033..fd3725ecd2 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -24,6 +24,7 @@ #include <mbgl/util/projection.hpp> #include <mbgl/util/default_styles.hpp> #include <mbgl/util/chrono.hpp> +#import <mbgl/util/run_loop.hpp> #import "Mapbox.h" #import "MGLFeature_Private.h" @@ -126,6 +127,11 @@ enum { MGLAnnotationTagNotFound = UINT32_MAX }; /// the annotation itself. typedef std::map<MGLAnnotationTag, MGLAnnotationContext> MGLAnnotationContextMap; +/// Initializes the run loop shim that lives on the main thread. +void MGLinitializeRunLoop() { + static mbgl::util::RunLoop mainRunLoop; +} + mbgl::util::UnitBezier MGLUnitBezierForMediaTimingFunction(CAMediaTimingFunction *function) { if ( ! function) @@ -357,6 +363,8 @@ public: - (void)commonInit { + MGLinitializeRunLoop(); + _isTargetingInterfaceBuilder = NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent; _opaque = YES; diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 8fca7b86ff..d61b336c9f 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -30,6 +30,7 @@ #import <mbgl/math/wrap.hpp> #import <mbgl/util/constants.hpp> #import <mbgl/util/chrono.hpp> +#import <mbgl/util/run_loop.hpp> #import <unordered_map> #import <unordered_set> @@ -112,6 +113,11 @@ NSImage *MGLDefaultMarkerImage() { return [[NSImage alloc] initWithContentsOfFile:path]; } +/// Initializes the run loop shim that lives on the main thread. +void MGLinitializeRunLoop() { + static mbgl::util::RunLoop mainRunLoop; +} + /// Converts a media timing function into a unit bezier object usable in mbgl. mbgl::util::UnitBezier MGLUnitBezierForMediaTimingFunction(CAMediaTimingFunction *function) { if (!function) { @@ -234,6 +240,8 @@ public: } - (void)commonInit { + MGLinitializeRunLoop(); + _isTargetingInterfaceBuilder = NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent; // Set up cross-platform controllers and resources. |