You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a TextBox with non empty Text is added to an AdornerLayer and no text box has ever been focused yet, the next Measure pass will run ApplyTemplate on the textbox, this will access the VisualLayerManager.TextSelectorLayer property, the getter will create the layer and Collection Was Modified while Enumeration exception will be thrown, because all those methods will be run from within VisualLayerManager's MeasureOverride, which iterates through its layers.
To Reproduce
Steps to reproduce the behavior:
[Fact]
public void TextBox_In_AdornerLayer_Will_Not_Cause_Collection_Modified_In_VisualLayerManager()
{
using (UnitTestApplication.Start(Services))
{
var button = new Button();
var root = new TestRoot()
{
Child = new VisualLayerManager()
{
Child = button
}
};
var adorner = new TextBox { Template = CreateTemplate(), Text = "a" };
var adornerLayer = AdornerLayer.GetAdornerLayer(button);
adornerLayer.Children.Add(adorner);
AdornerLayer.SetAdornedElement(adorner, button);
root.Measure(Size.Infinity);
}
}
Expected behavior
No crash
Environment
Avalonia-Version: 11.1.999-cibuild0044396-beta (latest master as of today)
The text was updated successfully, but these errors were encountered:
Describe the bug
When a TextBox with non empty Text is added to an AdornerLayer and no text box has ever been focused yet, the next Measure pass will run ApplyTemplate on the textbox, this will access the
VisualLayerManager.TextSelectorLayer
property, the getter will create the layer andCollection Was Modified while Enumeration
exception will be thrown, because all those methods will be run from within VisualLayerManager's MeasureOverride, which iterates through its layers.To Reproduce
Steps to reproduce the behavior:
Expected behavior
No crash
Environment
The text was updated successfully, but these errors were encountered: