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

Null-check source before removing #11789

Merged
merged 1 commit into from
May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,13 @@ public Source removeSource(@NonNull String sourceId) {
return null;
}
Source source = getSource(sourceId);
return removeSource(source);
if (source != null) {
return removeSource(source);
}
return null;
}

@Nullable
public Source removeSource(@NonNull Source source) {
if (isDestroyedOn("removeSource")) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,20 @@ public void perform(UiController uiController, View view) {
});
}

@Test
public void testRemoveNonExistingSource() {
invoke(mapboxMap, (uiController, mapboxMap) -> mapboxMap.removeSource("source"));
}

@Test
public void testRemoveNonExistingLayer() {
invoke(mapboxMap, (uiController, mapboxMap) -> {
mapboxMap.removeLayer("layer");
mapboxMap.removeLayerAt(mapboxMap.getLayers().size() + 1);
mapboxMap.removeLayerAt(-1);
});
}

/**
* https://github.com/mapbox/mapbox-gl-native/issues/7973
*/
Expand Down