-
Notifications
You must be signed in to change notification settings - Fork 742
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(xLoad): [Android] Fix invalid x:Load reentrancy issue
This scenario may happen when `x:Load` is used with a visibility binding causing a invalid invocation of the ViewGroup.RemoveViewAt Android API.
- Loading branch information
1 parent
1a1b091
commit 9784464
Showing
4 changed files
with
133 additions
and
11 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
...untimeTests/Tests/Windows_UI_Xaml/Controls/When_xLoad_Visibility_While_Materializing.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<UserControl | ||
x:Class="Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml.Controls.When_xLoad_Visibility_While_Materializing" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:local="using:Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml.Controls" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<Grid> | ||
<local:When_xLoad_Visibility_While_Materializing_Content | ||
x:Name="item1" | ||
x:FieldModifier="public" | ||
x:Load="false" | ||
Visibility="{x:Bind Model.IsVisible, Mode=OneWay, FallbackValue=false}" /> | ||
</Grid> | ||
</UserControl> |
64 changes: 64 additions & 0 deletions
64
...imeTests/Tests/Windows_UI_Xaml/Controls/When_xLoad_Visibility_While_Materializing.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Controls.Primitives; | ||
using Windows.UI.Xaml.Data; | ||
using Windows.UI.Xaml.Input; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Navigation; | ||
|
||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 | ||
|
||
namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml.Controls | ||
{ | ||
public sealed partial class When_xLoad_Visibility_While_Materializing : UserControl | ||
{ | ||
public When_xLoad_Visibility_While_Materializing() | ||
{ | ||
Model = new Model(); | ||
|
||
Model.PropertyChanged += delegate { | ||
FindName("item1"); | ||
}; | ||
|
||
this.InitializeComponent(); | ||
} | ||
|
||
public Model Model { get; } | ||
} | ||
|
||
public class Model : System.ComponentModel.INotifyPropertyChanged | ||
{ | ||
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; | ||
|
||
private bool _isVisible; | ||
|
||
public bool IsVisible | ||
{ | ||
get { return _isVisible; } | ||
set | ||
{ | ||
_isVisible = value; | ||
|
||
PropertyChanged.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(nameof(IsVisible))); | ||
} | ||
} | ||
|
||
} | ||
|
||
public partial class When_xLoad_Visibility_While_Materializing_Content : UserControl | ||
{ | ||
public When_xLoad_Visibility_While_Materializing_Content() | ||
{ | ||
Instances++; | ||
} | ||
|
||
public static int Instances { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters