Browse Source

Fix not handling first window creation (#14553)

release/11.0.9
Max Katz 2 years ago
parent
commit
b1670ab2c7
  1. 12
      src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs

12
src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs

@ -68,7 +68,7 @@ namespace Avalonia.Controls.ApplicationLifetimes
return DoShutdown(new ShutdownRequestedEventArgs(), true, false, exitCode);
}
internal void SetupCore(string[] args)
internal void SubscribeGlobalEvents()
{
if (_compositeDisposable is not null)
{
@ -76,7 +76,7 @@ namespace Avalonia.Controls.ApplicationLifetimes
// Until developer started it manually later. To avoid API breaking changes, it will execute Setup method twice.
return;
}
_compositeDisposable = new CompositeDisposable(
Window.WindowOpenedEvent.AddClassHandler(typeof(Window), (sender, _) =>
{
@ -91,7 +91,12 @@ namespace Avalonia.Controls.ApplicationLifetimes
var window = (Window)sender!;
_windows.Remove(window);
HandleWindowClosed(window);
}));
}));
}
internal void SetupCore(string[] args)
{
SubscribeGlobalEvents();
Startup?.Invoke(this, new ControlledApplicationLifetimeStartupEventArgs(args));
@ -214,6 +219,7 @@ namespace Avalonia
{
var lifetime = builder.LifetimeOverride?.Invoke(typeof(ClassicDesktopStyleApplicationLifetime)) as ClassicDesktopStyleApplicationLifetime
?? new ClassicDesktopStyleApplicationLifetime();
lifetime.SubscribeGlobalEvents();
lifetime.Args = args;
lifetimeBuilder?.Invoke(lifetime);

Loading…
Cancel
Save