From: Gerald Versluis Date: Fri, 9 Aug 2019 00:51:06 +0000 (+0200) Subject: [Bug] NullReferenceException Closing Window During Animation (#7067) X-Git-Tag: accepted/tizen/5.5/unified/20200421.150457~232^2~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d75fa4fa9260496962099dcf2fae8ad30aee1349;p=platform%2Fcore%2Fcsapi%2Fxsf.git [Bug] NullReferenceException Closing Window During Animation (#7067) * Added null check to current application for WPF * Apply suggestions from code review Co-Authored-By: Samantha Houts fixes #7061 --- diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7061.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7061.cs new file mode 100644 index 0000000..5b06eaf --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7061.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; + +namespace Xamarin.Forms.Controls.Issues +{ + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Github, 7061, "[Bug] NullReferenceException Closing Window During Animation", PlatformAffected.UWP)] + public class Issue7061 : TestContentPage + { + Label _animatedLabel = new Label { Text = "Scaling out" }; + Label _explanationLabel = new Label { Text = "When you close the app while the animation is still running you should not get an exception" }; + + protected override void Init() + { + var stack = new StackLayout + { + HorizontalOptions = LayoutOptions.Center, + VerticalOptions = LayoutOptions.Center + }; + + stack.Children.Add(_explanationLabel); + stack.Children.Add(_animatedLabel); + + Content = stack; + } + + protected override void OnAppearing() + { + base.OnAppearing(); + + _animatedLabel.ScaleTo(10, length: (uint)TimeSpan.FromMinutes(1).TotalMilliseconds); + } + } +} diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index b80806b..1ac48fb 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -21,6 +21,7 @@ Code + diff --git a/Xamarin.Forms.Platform.WPF/WPFPlatformServices.cs b/Xamarin.Forms.Platform.WPF/WPFPlatformServices.cs index 8978807..ae53ab8 100644 --- a/Xamarin.Forms.Platform.WPF/WPFPlatformServices.cs +++ b/Xamarin.Forms.Platform.WPF/WPFPlatformServices.cs @@ -30,7 +30,7 @@ namespace Xamarin.Forms.Platform.WPF public void BeginInvokeOnMainThread(Action action) { - System.Windows.Application.Current.Dispatcher.BeginInvoke(action); + System.Windows.Application.Current?.Dispatcher.BeginInvoke(action); } public Ticker CreateTicker()