summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamantha Houts <samantha@teamredwall.com>2016-06-16 10:09:22 -0700
committerRui Marinho <me@ruimarinho.net>2016-06-16 18:09:22 +0100
commitaf6ac9649f71d1557dffa3dc3357868016ebc1e7 (patch)
treef46a823ac63d614991f48d119f32821c2c8854ca
parent7ae79f49072d4543da80eaf443e214fdfa02ed9c (diff)
downloadxamarin-forms-af6ac9649f71d1557dffa3dc3357868016ebc1e7.tar.gz
xamarin-forms-af6ac9649f71d1557dffa3dc3357868016ebc1e7.tar.bz2
xamarin-forms-af6ac9649f71d1557dffa3dc3357868016ebc1e7.zip
[UWP] MasterDetailControl will no longer null out the TCS before it is used. (#227)
* [UWP] Don't null the _commandBarTcs too soon * Add repro for 41842
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla41842.cs35
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems1
-rw-r--r--Xamarin.Forms.Platform.UAP/MasterDetailControl.cs14
3 files changed, 43 insertions, 7 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla41842.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla41842.cs
new file mode 100644
index 00000000..f5714233
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla41842.cs
@@ -0,0 +1,35 @@
+using System;
+
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Bugzilla, 41842, "Set MasterDetailPage.Detail = New Page() twice will crash the application when set MasterBehavior = MasterBehavior.Split", PlatformAffected.WinRT)]
+ public class Bugzilla41842 : TestMasterDetailPage
+ {
+ protected override void Init()
+ {
+ MasterBehavior = MasterBehavior.Split;
+
+ Master = new Page() { Title = "Master" };
+
+ Detail = new NavigationPage(new Page());
+ Detail = new NavigationPage(new ContentPage { Content = new Label { Text = "Success" } });
+ }
+
+#if UITEST
+ [Test]
+ public void Bugzilla41842Test()
+ {
+ RunningApp.WaitForElement(q => q.Marked("Success"));
+ }
+#endif
+ }
+}
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 5c963249..1e9d1ea0 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
@@ -153,6 +153,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39458.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39853.cs" />
<Compile Include="$(MSBuildThisFileDirectory)TestPages\ScreenshotConditionalApp.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla41842.cs" />
<Compile Include="$(MSBuildThisFileDirectory)_Template.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue1028.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue1075.cs" />
diff --git a/Xamarin.Forms.Platform.UAP/MasterDetailControl.cs b/Xamarin.Forms.Platform.UAP/MasterDetailControl.cs
index 9ec03f8d..6787ccec 100644
--- a/Xamarin.Forms.Platform.UAP/MasterDetailControl.cs
+++ b/Xamarin.Forms.Platform.UAP/MasterDetailControl.cs
@@ -167,7 +167,11 @@ namespace Xamarin.Forms.Platform.UWP
_commandBarTcs = new TaskCompletionSource<CommandBar>();
ApplyTemplate();
- return _commandBarTcs.Task;
+
+ var commandBarFromTemplate = _commandBarTcs.Task;
+ _commandBarTcs = null;
+
+ return commandBarFromTemplate;
}
protected override void OnApplyTemplate()
@@ -193,12 +197,8 @@ namespace Xamarin.Forms.Platform.UWP
UpdateMode();
- TaskCompletionSource<CommandBar> tcs = _commandBarTcs;
- if (tcs != null)
- {
- _commandBarTcs = null;
- tcs.SetResult(_commandBar);
- }
+ if (_commandBarTcs != null)
+ _commandBarTcs.SetResult(_commandBar);
}
static void OnShouldShowSplitModeChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)