summaryrefslogtreecommitdiff
path: root/platform/ios
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2016-11-29 08:56:59 -0800
committerGitHub <noreply@github.com>2016-11-29 08:56:59 -0800
commitd830c48e4a6d656284df930a5fda03ba8f1521cc (patch)
tree341fcd663c5a790f8cc5dda917ccb11f718a5734 /platform/ios
parent83e134eb9f2a8737d2ce008cd7564b4df0777c39 (diff)
downloadqtlocation-mapboxgl-d830c48e4a6d656284df930a5fda03ba8f1521cc.tar.gz
[ios, macos] Refcount view activations (#7208)
This adds a ref count to guard against calling activate after it has already been called. This can happen when a layer is added during certain map lifecycle methods like MapChangeWillStartRenderingFrame that also triggers activation. This also protects against issues related to a deactivation of the context happening in an inner scope while an outer scope is still expecting to be able to use the context.
Diffstat (limited to 'platform/ios')
-rw-r--r--platform/ios/src/MGLMapView.mm12
1 files changed, 12 insertions, 0 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index b1ecf1c415..e36f0299e8 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -5093,16 +5093,28 @@ public:
void activate() override
{
+ if (activationCount++)
+ {
+ return;
+ }
+
[EAGLContext setCurrentContext:nativeView.context];
}
void deactivate() override
{
+ if (--activationCount)
+ {
+ return;
+ }
+
[EAGLContext setCurrentContext:nil];
}
private:
__weak MGLMapView *nativeView = nullptr;
+
+ NSUInteger activationCount = 0;
};
@end