From fec4df44b0ea62788937c5f81548b7af9681ad67 Mon Sep 17 00:00:00 2001 From: Julien Lebosquain Date: Tue, 7 Feb 2023 17:15:16 +0100 Subject: [PATCH] Nullability fixes for Avalonia.Controls.ColorPicker --- .../ColorSlider/ColorSlider.cs | 49 +++++++------------ 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/src/Avalonia.Controls.ColorPicker/ColorSlider/ColorSlider.cs b/src/Avalonia.Controls.ColorPicker/ColorSlider/ColorSlider.cs index be320246b3..dd5e7d5b01 100644 --- a/src/Avalonia.Controls.ColorPicker/ColorSlider/ColorSlider.cs +++ b/src/Avalonia.Controls.ColorPicker/ColorSlider/ColorSlider.cs @@ -41,18 +41,6 @@ namespace Avalonia.Controls.Primitives { } - /// - protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) - { - base.OnAttachedToVisualTree(e); - } - - /// - protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) - { - base.OnDetachedFromVisualTree(e); - } - /// /// Updates the visual state of the control by applying latest PseudoClasses. /// @@ -123,28 +111,25 @@ namespace Avalonia.Controls.Primitives IsAlphaMaxForced, IsSaturationValueMaxForced); - if (bgraPixelData != null) + if (_backgroundBitmap != null) { - if (_backgroundBitmap != null) - { - // TODO: CURRENTLY DISABLED DUE TO INTERMITTENT CRASHES IN SKIA/RENDERER - // - // Re-use the existing WriteableBitmap - // This assumes the height, width and byte counts are the same and must be set to null - // elsewhere if that assumption is ever not true. - // ColorPickerHelpers.UpdateBitmapFromPixelData(_backgroundBitmap, bgraPixelData); - - // TODO: ALSO DISABLED DISPOSE DUE TO INTERMITTENT CRASHES - //_backgroundBitmap?.Dispose(); - _backgroundBitmap = ColorPickerHelpers.CreateBitmapFromPixelData(bgraPixelData, pixelWidth, pixelHeight); - } - else - { - _backgroundBitmap = ColorPickerHelpers.CreateBitmapFromPixelData(bgraPixelData, pixelWidth, pixelHeight); - } - - Background = new ImageBrush(_backgroundBitmap); + // TODO: CURRENTLY DISABLED DUE TO INTERMITTENT CRASHES IN SKIA/RENDERER + // + // Re-use the existing WriteableBitmap + // This assumes the height, width and byte counts are the same and must be set to null + // elsewhere if that assumption is ever not true. + // ColorPickerHelpers.UpdateBitmapFromPixelData(_backgroundBitmap, bgraPixelData); + + // TODO: ALSO DISABLED DISPOSE DUE TO INTERMITTENT CRASHES + //_backgroundBitmap?.Dispose(); + _backgroundBitmap = ColorPickerHelpers.CreateBitmapFromPixelData(bgraPixelData, pixelWidth, pixelHeight); } + else + { + _backgroundBitmap = ColorPickerHelpers.CreateBitmapFromPixelData(bgraPixelData, pixelWidth, pixelHeight); + } + + Background = new ImageBrush(_backgroundBitmap); } }