diff options
author | Jesse Bounds <jesse@rebounds.net> | 2016-11-29 08:56:59 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-29 08:56:59 -0800 |
commit | d830c48e4a6d656284df930a5fda03ba8f1521cc (patch) | |
tree | 341fcd663c5a790f8cc5dda917ccb11f718a5734 /platform/macos | |
parent | 83e134eb9f2a8737d2ce008cd7564b4df0777c39 (diff) | |
download | qtlocation-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/macos')
-rw-r--r-- | platform/macos/src/MGLMapView.mm | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 50b77bc814..ba07048262 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -2611,11 +2611,19 @@ public: } void activate() override { + if (activationCount++) { + return; + } + MGLOpenGLLayer *layer = (MGLOpenGLLayer *)nativeView.layer; [layer.openGLContext makeCurrentContext]; } void deactivate() override { + if (--activationCount) { + return; + } + [NSOpenGLContext clearCurrentContext]; } @@ -2661,6 +2669,9 @@ private: /// The current framebuffer of the NSOpenGLLayer we are painting to. GLint fbo = 0; + + /// The reference counted count of activation calls + NSUInteger activationCount = 0; }; @end |