diff options
author | adrianknight89 <adrianknight89@outlook.com> | 2016-11-24 13:34:46 -0600 |
---|---|---|
committer | Stephane Delcroix <stephane@delcroix.org> | 2016-11-24 20:34:46 +0100 |
commit | 1f3d5ecd260c836563b34efe2be3f8e287582eaf (patch) | |
tree | 640e183debe00384e74b7c35a169417c136ec869 | |
parent | 57152381377d2b09f749f46b829add58f1ab1930 (diff) | |
download | xamarin-forms-1f3d5ecd260c836563b34efe2be3f8e287582eaf.tar.gz xamarin-forms-1f3d5ecd260c836563b34efe2be3f8e287582eaf.tar.bz2 xamarin-forms-1f3d5ecd260c836563b34efe2be3f8e287582eaf.zip |
fix weakreferences (#558)
-rw-r--r-- | Xamarin.Forms.Core/MessagingCenter.cs | 2 | ||||
-rw-r--r-- | Xamarin.Forms.Pages/DataSourceBinding.cs | 7 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.WP8/NavigationMenuRenderer.cs | 5 |
3 files changed, 6 insertions, 8 deletions
diff --git a/Xamarin.Forms.Core/MessagingCenter.cs b/Xamarin.Forms.Core/MessagingCenter.cs index 973531ab..0efb3a37 100644 --- a/Xamarin.Forms.Core/MessagingCenter.cs +++ b/Xamarin.Forms.Core/MessagingCenter.cs @@ -91,7 +91,7 @@ namespace Xamarin.Forms List<Tuple<WeakReference, Action<object, object>>> actionsCopy = actions.ToList(); foreach (Tuple<WeakReference, Action<object, object>> action in actionsCopy) { - if (action.Item1.IsAlive && actions.Contains(action)) + if (action.Item1.Target != null && actions.Contains(action)) action.Item2(sender, args); } } diff --git a/Xamarin.Forms.Pages/DataSourceBinding.cs b/Xamarin.Forms.Pages/DataSourceBinding.cs index 44af47b4..7491ca30 100644 --- a/Xamarin.Forms.Pages/DataSourceBinding.cs +++ b/Xamarin.Forms.Pages/DataSourceBinding.cs @@ -120,11 +120,8 @@ namespace Xamarin.Forms.Pages { base.Unapply(); - if (_dataSourceRef != null && _dataSourceRef.IsAlive) - { - var dataSourceProviderer = (IDataSourceProvider)_dataSourceRef.Target; - dataSourceProviderer?.UnmaskKey(_path); - } + var dataSourceProviderer = (IDataSourceProvider)_dataSourceRef?.Target; + dataSourceProviderer?.UnmaskKey(_path); _expression?.Unapply(); } diff --git a/Xamarin.Forms.Platform.WP8/NavigationMenuRenderer.cs b/Xamarin.Forms.Platform.WP8/NavigationMenuRenderer.cs index c5a983d3..83af320b 100644 --- a/Xamarin.Forms.Platform.WP8/NavigationMenuRenderer.cs +++ b/Xamarin.Forms.Platform.WP8/NavigationMenuRenderer.cs @@ -72,8 +72,9 @@ namespace Xamarin.Forms.Platform.WinPhone var weakRef = new WeakReference(hubTile); SizeChanged += (sender, args) => { - if (weakRef.IsAlive) - ((HubTile)weakRef.Target).Size = GetSize(); + var hTile = (HubTile)weakRef.Target; + if (hTile != null) + hTile.Size = GetSize(); ((IVisualElementController)Element).NativeSizeChanged(); }; |