From dcac85f184a7fce4297904358ab2099efc031da8 Mon Sep 17 00:00:00 2001 From: Eric Maupin Date: Mon, 14 Jan 2019 17:01:03 -0500 Subject: [mac] ViewModel is allowed to be null --- .../Controls/Custom/BrushTabViewController.cs | 2 +- .../Controls/Custom/PropertyButton.cs | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'Xamarin.PropertyEditing.Mac/Controls/Custom') diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs index dd63955..dc956e3 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs @@ -58,7 +58,7 @@ namespace Xamarin.PropertyEditing.Mac this.inhibitSelection = true; base.OnViewModelChanged (oldModel); - var existing = new HashSet (ViewModel?.BrushTypes?.Values ?? Array.Empty ()); + var existing = new HashSet (oldModel?.BrushTypes?.Values ?? Array.Empty ()); existing.IntersectWith (this.brushTypeTable.Keys); var removed = new HashSet (this.brushTypeTable.Keys); diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs index fab17c6..9846e2c 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs @@ -18,14 +18,15 @@ namespace Xamarin.PropertyEditing.Mac { get { return viewModel; } set { - if (viewModel != null) { - viewModel.PropertyChanged -= OnPropertyChanged; + if (this.viewModel != null) { + this.viewModel.PropertyChanged -= OnPropertyChanged; } - viewModel = value; - viewModel.PropertyChanged += OnPropertyChanged; - - ValueSourceChanged (viewModel.ValueSource); + this.viewModel = value; + if (this.viewModel != null) { + this.viewModel.PropertyChanged += OnPropertyChanged; + ValueSourceChanged (this.viewModel.ValueSource); + } } } -- cgit v1.2.3