Skip to content

Commit 81e5fe8

Browse files
committed
Merge branch 'stable/0.10.x' of https://github.com/AvaloniaUI/Avalonia into stable/0.10.x
2 parents fa7294a + 4f3fa13 commit 81e5fe8

File tree

6 files changed

+51
-4
lines changed

6 files changed

+51
-4
lines changed

src/Avalonia.Base/Threading/ThreadSafeObjectPool.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ namespace Avalonia.Threading
55
public class ThreadSafeObjectPool<T> where T : class, new()
66
{
77
private Stack<T> _stack = new Stack<T>();
8-
private object _lock = new object();
98
public static ThreadSafeObjectPool<T> Default { get; } = new ThreadSafeObjectPool<T>();
109

1110
public T Get()
1211
{
13-
lock (_lock)
12+
lock (_stack)
1413
{
1514
if(_stack.Count == 0)
1615
return new T();

src/Avalonia.Controls/ItemsControl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ protected static IInputElement GetNextControl(
519519
}
520520

521521
c = result;
522-
} while (c != null && c != from);
522+
} while (c != null && c != from && direction != NavigationDirection.First && direction != NavigationDirection.Last);
523523

524524
return null;
525525
}

src/Avalonia.Controls/Platform/DefaultMenuInteractionHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ protected internal virtual void PointerReleased(object sender, PointerReleasedEv
412412

413413
protected internal virtual void MenuOpened(object sender, RoutedEventArgs e)
414414
{
415-
if (e.Source == Menu)
415+
if (e.Source is Menu)
416416
{
417417
Menu?.MoveSelection(NavigationDirection.First, true);
418418
}

src/Skia/Avalonia.Skia/DrawingContextImpl.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ public DrawingContextImpl(CreateInfo createInfo, params IDisposable[] disposable
126126
SKCanvas ISkiaDrawingContextImpl.SkCanvas => Canvas;
127127
SKSurface ISkiaDrawingContextImpl.SkSurface => Surface;
128128
GRContext ISkiaDrawingContextImpl.GrContext => _grContext;
129+
double ISkiaDrawingContextImpl.CurrentOpacity => _currentOpacity;
129130

130131
/// <inheritdoc />
131132
public void Clear(Color color)

src/Skia/Avalonia.Skia/ISkiaDrawingContextImpl.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ public interface ISkiaDrawingContextImpl : IDrawingContextImpl
88
SKCanvas SkCanvas { get; }
99
GRContext GrContext { get; }
1010
SKSurface SkSurface { get; }
11+
double CurrentOpacity { get; }
1112
}
1213
}

tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using System.Collections.Specialized;
55
using System.ComponentModel;
66
using System.Linq;
7+
using System.Reactive.Disposables;
8+
using System.Threading.Tasks;
79
using Avalonia.Collections;
810
using Avalonia.Controls.Presenters;
911
using Avalonia.Controls.Primitives;
@@ -1610,6 +1612,50 @@ public void MoveSelection_Wrap_Does_Not_Hang_With_No_Focusable_Controls()
16101612
target.MoveSelection(NavigationDirection.Next, true);
16111613
}
16121614

1615+
[Fact(Timeout = 2000)]
1616+
public async Task MoveSelection_Does_Not_Hang_With_No_Focusable_Controls_And_Moving_Selection_To_The_First_Item()
1617+
{
1618+
var target = new TestSelector
1619+
{
1620+
Template = Template(),
1621+
Items = new[]
1622+
{
1623+
new ListBoxItem { Focusable = false },
1624+
new ListBoxItem(),
1625+
}
1626+
};
1627+
1628+
target.Measure(new Size(100, 100));
1629+
target.Arrange(new Rect(0, 0, 100, 100));
1630+
1631+
// Timeout in xUnit doesen't work with synchronous methods so we need to apply hack below.
1632+
// https://github.com/xunit/xunit/issues/2222
1633+
await Task.Run(() => target.MoveSelection(NavigationDirection.First, true));
1634+
Assert.Equal(-1, target.SelectedIndex);
1635+
}
1636+
1637+
[Fact(Timeout = 2000)]
1638+
public async Task MoveSelection_Does_Not_Hang_With_No_Focusable_Controls_And_Moving_Selection_To_The_Last_Item()
1639+
{
1640+
var target = new TestSelector
1641+
{
1642+
Template = Template(),
1643+
Items = new[]
1644+
{
1645+
new ListBoxItem(),
1646+
new ListBoxItem { Focusable = false },
1647+
}
1648+
};
1649+
1650+
target.Measure(new Size(100, 100));
1651+
target.Arrange(new Rect(0, 0, 100, 100));
1652+
1653+
// Timeout in xUnit doesen't work with synchronous methods so we need to apply hack below.
1654+
// https://github.com/xunit/xunit/issues/2222
1655+
await Task.Run(() => target.MoveSelection(NavigationDirection.Last, true));
1656+
Assert.Equal(-1, target.SelectedIndex);
1657+
}
1658+
16131659
[Fact]
16141660
public void MoveSelection_Does_Select_Disabled_Controls()
16151661
{

0 commit comments

Comments
 (0)