summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamian Karzon <dkarzon@outlook.com>2017-07-04 22:08:58 +1000
committerRui Marinho <me@ruimarinho.net>2017-07-04 13:08:58 +0100
commit747b01b5bb9b18fc60e2d00a7dffa70d36475e98 (patch)
tree81a96cb0a7edadb88eb1fdf662062390f61e7b57
parent0f3250cc8a1119d0281994c3320483695fea5f3f (diff)
downloadxamarin-forms-747b01b5bb9b18fc60e2d00a7dffa70d36475e98.tar.gz
xamarin-forms-747b01b5bb9b18fc60e2d00a7dffa70d36475e98.tar.bz2
xamarin-forms-747b01b5bb9b18fc60e2d00a7dffa70d36475e98.zip
[iOS] Fix for disposing a map causing a null reference (#1027)
-rw-r--r--Xamarin.Forms.Maps.iOS/MapRenderer.cs7
1 files changed, 5 insertions, 2 deletions
diff --git a/Xamarin.Forms.Maps.iOS/MapRenderer.cs b/Xamarin.Forms.Maps.iOS/MapRenderer.cs
index 2fac61a8..7940a575 100644
--- a/Xamarin.Forms.Maps.iOS/MapRenderer.cs
+++ b/Xamarin.Forms.Maps.iOS/MapRenderer.cs
@@ -198,8 +198,11 @@ namespace Xamarin.Forms.Maps.MacOS
var mkMapView = (MKMapView)Control;
mkMapView.RegionChanged -= MkMapViewOnRegionChanged;
mkMapView.GetViewForAnnotation = null;
- mkMapView.Delegate.Dispose();
- mkMapView.Delegate = null;
+ if (mkMapView.Delegate != null)
+ {
+ mkMapView.Delegate.Dispose();
+ mkMapView.Delegate = null;
+ }
mkMapView.RemoveFromSuperview();
#if __MOBILE__
if (FormsMaps.IsiOs9OrNewer)