Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

[ios, macos] Take back source and layer ownership on removal - #7048

Merged
boundsj merged 1 commit into
release-ios-v3.4.0from
boundsj-darwin-return-source-layer-ownership
Nov 14, 2016
Merged

boundsj merged 1 commit into
release-ios-v3.4.0from
boundsj-darwin-return-source-layer-ownership

Conversation

@boundsj

@boundsj boundsj commented Nov 14, 2016

Copy link
Copy Markdown
Contributor

If a source or layer is removed from the style, recapture the unique pointer ownership. This makes it safe to add back sources and layers after they have been removed.

Fixes iOS and macOS portion of #6959

cc @1ec5 @frederoni @incanus

@boundsj boundsj added iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS refactor runtime styling ✓ ready for review labels Nov 14, 2016
@boundsj boundsj added this to the ios-v3.4.0 milestone Nov 14, 2016
@boundsj boundsj self-assigned this Nov 14, 2016
@mention-bot

Copy link
Copy Markdown

@boundsj, thanks for your PR! By analyzing the history of the files in this pull request, we identified @fabian-guerra, @frederoni and @1ec5 to be potential reviewers.

@boundsj
boundsj force-pushed the boundsj-darwin-return-source-layer-ownership branch from aa8dac9 to b2638b4 Compare November 14, 2016 17:11
If a source or layer is removed from the style, recapture the
unique pointer ownership. This makes it safe to add back sources
and layers after they have been removed.
@boundsj
boundsj force-pushed the boundsj-darwin-return-source-layer-ownership branch from b2638b4 to cd51255 Compare November 14, 2016 17:11
@boundsj

boundsj commented Nov 14, 2016 •

Copy link
Copy Markdown
Contributor Author

Not that it is advisable, but this change makes it safe to write layer/source toggling logic that looks something like:

// Assume you have pointers to "layer" and "source" instances that were previously added

if (toggleOff) {
    [self.mapView.style removeLayer:layer];
    [self.mapView.style removeSource:source];
} else {
    [self.mapView.style addSource:source];
    [self.mapView.style addLayer:layer];
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS refactor runtime styling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants