зеркало из https://github.com/DeGsoft/maui-linux.git
Fix NullReferenceException in VisualElement finalize. (#701)
This commit is contained in:
Родитель
fb024a6e62
Коммит
a11e4c638b
|
@ -0,0 +1,80 @@
|
|||
using System;
|
||||
using Xamarin.Forms.CustomAttributes;
|
||||
using Xamarin.Forms.Internals;
|
||||
|
||||
#if UITEST
|
||||
using Xamarin.UITest;
|
||||
using NUnit.Framework;
|
||||
#endif
|
||||
|
||||
namespace Xamarin.Forms.Controls.Issues
|
||||
{
|
||||
[Preserve(AllMembers = true)]
|
||||
[Issue(IssueTracker.Bugzilla, 51503, "NullReferenceException on VisualElement Finalize", PlatformAffected.All)]
|
||||
public class Bugzilla51503 : TestNavigationPage
|
||||
{
|
||||
protected override void Init()
|
||||
{
|
||||
PushAsync(new RootPage());
|
||||
}
|
||||
|
||||
[Preserve(AllMembers = true)]
|
||||
class RootPage : ContentPage
|
||||
{
|
||||
public RootPage()
|
||||
{
|
||||
Button button = new Button
|
||||
{
|
||||
AutomationId = "Button",
|
||||
Text = "Open"
|
||||
};
|
||||
|
||||
button.Clicked += Button_Clicked;
|
||||
|
||||
Content = button;
|
||||
}
|
||||
|
||||
async void Button_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
|
||||
await Navigation.PushAsync(new ChildPage());
|
||||
}
|
||||
}
|
||||
|
||||
[Preserve(AllMembers = true)]
|
||||
class ChildPage : ContentPage
|
||||
{
|
||||
public ChildPage()
|
||||
{
|
||||
Content = new Label
|
||||
{
|
||||
AutomationId = "VisualElement",
|
||||
Text = "Navigate 3 times to this page",
|
||||
Triggers =
|
||||
{
|
||||
new EventTrigger()
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#if UITEST
|
||||
[Test]
|
||||
public void Issue51503Test()
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
RunningApp.WaitForElement(q => q.Marked("Button"));
|
||||
|
||||
RunningApp.Tap(q => q.Marked("Button"));
|
||||
|
||||
RunningApp.WaitForElement(q => q.Marked("VisualElement"));
|
||||
|
||||
RunningApp.Back();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -222,6 +222,7 @@
|
|||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla28650.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla37431.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla44777.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla51503.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)_Template.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue1028.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue1075.cs" />
|
||||
|
|
|
@ -790,7 +790,7 @@ namespace Xamarin.Forms
|
|||
}
|
||||
|
||||
if (!GetIsDefault(TriggersProperty)) {
|
||||
var triggers = GetValue(TriggersProperty) as AttachedCollection<Trigger>;
|
||||
var triggers = GetValue(TriggersProperty) as AttachedCollection<TriggerBase>;
|
||||
triggers.DetachFrom(this);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче