Browse Source

Merge branch 'stable/0.10.x' of https://github.com/AvaloniaUI/Avalonia into stable/0.10.x

7963-stable
Takoooooo 4 years ago
parent
commit
81e5fe8ffc
  1. 3
      src/Avalonia.Base/Threading/ThreadSafeObjectPool.cs
  2. 2
      src/Avalonia.Controls/ItemsControl.cs
  3. 2
      src/Avalonia.Controls/Platform/DefaultMenuInteractionHandler.cs
  4. 1
      src/Skia/Avalonia.Skia/DrawingContextImpl.cs
  5. 1
      src/Skia/Avalonia.Skia/ISkiaDrawingContextImpl.cs
  6. 46
      tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs

3
src/Avalonia.Base/Threading/ThreadSafeObjectPool.cs

@ -5,12 +5,11 @@ namespace Avalonia.Threading
public class ThreadSafeObjectPool<T> where T : class, new()
{
private Stack<T> _stack = new Stack<T>();
private object _lock = new object();
public static ThreadSafeObjectPool<T> Default { get; } = new ThreadSafeObjectPool<T>();
public T Get()
{
lock (_lock)
lock (_stack)
{
if(_stack.Count == 0)
return new T();

2
src/Avalonia.Controls/ItemsControl.cs

@ -519,7 +519,7 @@ namespace Avalonia.Controls
}
c = result;
} while (c != null && c != from);
} while (c != null && c != from && direction != NavigationDirection.First && direction != NavigationDirection.Last);
return null;
}

2
src/Avalonia.Controls/Platform/DefaultMenuInteractionHandler.cs

@ -412,7 +412,7 @@ namespace Avalonia.Controls.Platform
protected internal virtual void MenuOpened(object sender, RoutedEventArgs e)
{
if (e.Source == Menu)
if (e.Source is Menu)
{
Menu?.MoveSelection(NavigationDirection.First, true);
}

1
src/Skia/Avalonia.Skia/DrawingContextImpl.cs

@ -126,6 +126,7 @@ namespace Avalonia.Skia
SKCanvas ISkiaDrawingContextImpl.SkCanvas => Canvas;
SKSurface ISkiaDrawingContextImpl.SkSurface => Surface;
GRContext ISkiaDrawingContextImpl.GrContext => _grContext;
double ISkiaDrawingContextImpl.CurrentOpacity => _currentOpacity;
/// <inheritdoc />
public void Clear(Color color)

1
src/Skia/Avalonia.Skia/ISkiaDrawingContextImpl.cs

@ -8,5 +8,6 @@ namespace Avalonia.Skia
SKCanvas SkCanvas { get; }
GRContext GrContext { get; }
SKSurface SkSurface { get; }
double CurrentOpacity { get; }
}
}

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

@ -4,6 +4,8 @@ using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Reactive.Disposables;
using System.Threading.Tasks;
using Avalonia.Collections;
using Avalonia.Controls.Presenters;
using Avalonia.Controls.Primitives;
@ -1610,6 +1612,50 @@ namespace Avalonia.Controls.UnitTests.Primitives
target.MoveSelection(NavigationDirection.Next, true);
}
[Fact(Timeout = 2000)]
public async Task MoveSelection_Does_Not_Hang_With_No_Focusable_Controls_And_Moving_Selection_To_The_First_Item()
{
var target = new TestSelector
{
Template = Template(),
Items = new[]
{
new ListBoxItem { Focusable = false },
new ListBoxItem(),
}
};
target.Measure(new Size(100, 100));
target.Arrange(new Rect(0, 0, 100, 100));
// Timeout in xUnit doesen't work with synchronous methods so we need to apply hack below.
// https://github.com/xunit/xunit/issues/2222
await Task.Run(() => target.MoveSelection(NavigationDirection.First, true));
Assert.Equal(-1, target.SelectedIndex);
}
[Fact(Timeout = 2000)]
public async Task MoveSelection_Does_Not_Hang_With_No_Focusable_Controls_And_Moving_Selection_To_The_Last_Item()
{
var target = new TestSelector
{
Template = Template(),
Items = new[]
{
new ListBoxItem(),
new ListBoxItem { Focusable = false },
}
};
target.Measure(new Size(100, 100));
target.Arrange(new Rect(0, 0, 100, 100));
// Timeout in xUnit doesen't work with synchronous methods so we need to apply hack below.
// https://github.com/xunit/xunit/issues/2222
await Task.Run(() => target.MoveSelection(NavigationDirection.Last, true));
Assert.Equal(-1, target.SelectedIndex);
}
[Fact]
public void MoveSelection_Does_Select_Disabled_Controls()
{

Loading…
Cancel
Save