mirror of
https://github.com/microsoft/WSL.git
synced 2025-12-11 04:35:57 -06:00
Refactor cleanup logic into dedicated method
Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
This commit is contained in:
parent
20cc767c58
commit
8bd45c84ab
@ -108,20 +108,25 @@ public sealed partial class OOBEWindow : WindowEx, IDisposable
|
||||
AppWindow.Resize(size);
|
||||
}
|
||||
|
||||
private void CleanupEscapeAccelerator()
|
||||
{
|
||||
if (escapeAccelerator != null)
|
||||
{
|
||||
escapeAccelerator.Invoked -= OnCloseKeyboardAcceleratorInvoked;
|
||||
if (page != null)
|
||||
{
|
||||
page.KeyboardAccelerators.Remove(escapeAccelerator);
|
||||
}
|
||||
escapeAccelerator = null;
|
||||
}
|
||||
page = null;
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposedValue)
|
||||
{
|
||||
if (escapeAccelerator != null)
|
||||
{
|
||||
escapeAccelerator.Invoked -= OnCloseKeyboardAcceleratorInvoked;
|
||||
if (page != null)
|
||||
{
|
||||
page.KeyboardAccelerators.Remove(escapeAccelerator);
|
||||
}
|
||||
escapeAccelerator = null;
|
||||
}
|
||||
page = null;
|
||||
CleanupEscapeAccelerator();
|
||||
msgMonitor?.Dispose();
|
||||
settings.ColorValuesChanged -= Settings_ColorValuesChanged;
|
||||
this.Activated -= OnWindowActivated;
|
||||
@ -145,14 +150,7 @@ public sealed partial class OOBEWindow : WindowEx, IDisposable
|
||||
if (this.Content is Microsoft.UI.Xaml.Controls.Page p)
|
||||
{
|
||||
// Clean up any existing accelerator before creating a new one
|
||||
if (escapeAccelerator != null)
|
||||
{
|
||||
escapeAccelerator.Invoked -= OnCloseKeyboardAcceleratorInvoked;
|
||||
if (page != null)
|
||||
{
|
||||
page.KeyboardAccelerators.Remove(escapeAccelerator);
|
||||
}
|
||||
}
|
||||
CleanupEscapeAccelerator();
|
||||
|
||||
page = p;
|
||||
escapeAccelerator = new KeyboardAccelerator() { Key = VirtualKey.Escape };
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user