Skip to content

Commit 136c809

Browse files
authored
Fix: Fixed a crash that would occur when closing the main window (#16140)
1 parent 6a335a9 commit 136c809

File tree

4 files changed

+10
-29
lines changed

4 files changed

+10
-29
lines changed

src/Files.App/App.xaml.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ async Task ActivateAsync()
159159
}
160160

161161
await AppLifecycleHelper.InitializeAppComponentsAsync();
162-
163-
AppLifecycleHelper.IsLaunchInitialized = true;
164162
}
165163
}
166164

src/Files.App/Data/Items/WindowEx.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ public unsafe WindowEx(int minWidth = 400, int minHeight = 300)
106106
_oldWndProc = Marshal.GetDelegateForFunctionPointer<WNDPROC>(pOldWndProc);
107107

108108
Closed += WindowEx_Closed;
109-
Activated += WindowEx_Activated; ;
110109
}
111110

112111
private unsafe void StoreWindowPlacementData()
@@ -298,16 +297,9 @@ private void WindowEx_Closed(object sender, WindowEventArgs args)
298297
StoreWindowPlacementData();
299298
}
300299

301-
private void WindowEx_Activated(object sender, WindowActivatedEventArgs args)
302-
{
303-
if (AppLifecycleHelper.IsLaunchInitialized && SystemBackdrop is AppSystemBackdrop appSystemBackdrop)
304-
appSystemBackdrop.SystemBackdropConfiguration.IsInputActive = args.WindowActivationState is not WindowActivationState.Deactivated;
305-
}
306-
307300
public void Dispose()
308301
{
309302
Closed -= WindowEx_Closed;
310-
Activated -= WindowEx_Activated;
311303
}
312304
}
313305
}

src/Files.App/Helpers/Application/AppLifecycleHelper.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using CommunityToolkit.WinUI.Helpers;
55
using Files.App.Helpers.Application;
66
using Files.App.Services.SizeProvider;
7-
using Files.App.Storage.Storables;
87
using Files.App.Utils.Logger;
98
using Files.App.ViewModels.Settings;
109
using Microsoft.Extensions.DependencyInjection;
@@ -58,12 +57,6 @@ public static class AppLifecycleHelper
5857
_ => Constants.AssetPaths.StableLogo
5958
});
6059

61-
/// <summary>
62-
/// Gets or sets a value that indicates whether the application is ready to be interacted with.
63-
/// This is primarily used for DI container initialization check.
64-
/// </summary>
65-
public static bool IsLaunchInitialized { get; set; }
66-
6760
/// <summary>
6861
/// Initializes the app components.
6962
/// </summary>

src/Files.App/Helpers/UI/AppSystemBackdrop.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ internal sealed class AppSystemBackdrop : SystemBackdrop
1616
private XamlRoot root;
1717
private SystemBackdropTheme? prevTheme = null;
1818

19-
public SystemBackdropConfiguration SystemBackdropConfiguration { get; set; }
20-
2119
public AppSystemBackdrop(bool isSecondaryWindow = false)
2220
{
2321
this.isSecondaryWindow = isSecondaryWindow;
@@ -34,21 +32,21 @@ protected override void OnTargetConnected(ICompositionSupportsSystemBackdrop con
3432
base.OnTargetConnected(connectedTarget, xamlRoot);
3533
this.target = connectedTarget;
3634
this.root = xamlRoot;
37-
SystemBackdropConfiguration = GetDefaultSystemBackdropConfiguration(connectedTarget, xamlRoot);
38-
controller = GetSystemBackdropController(userSettingsService.AppearanceSettingsService.AppThemeBackdropMaterial, SystemBackdropConfiguration.Theme);
39-
controller?.SetSystemBackdropConfiguration(SystemBackdropConfiguration);
35+
var configuration = GetDefaultSystemBackdropConfiguration(connectedTarget, xamlRoot);
36+
controller = GetSystemBackdropController(userSettingsService.AppearanceSettingsService.AppThemeBackdropMaterial, configuration.Theme);
37+
controller?.SetSystemBackdropConfiguration(configuration);
4038
controller?.AddSystemBackdropTarget(connectedTarget);
4139
}
4240

4341
protected override void OnDefaultSystemBackdropConfigurationChanged(ICompositionSupportsSystemBackdrop target, XamlRoot xamlRoot)
4442
{
4543
base.OnDefaultSystemBackdropConfigurationChanged(target, xamlRoot);
46-
SystemBackdropConfiguration = GetDefaultSystemBackdropConfiguration(target, xamlRoot);
47-
if (controller is not DesktopAcrylicController acrylicController || acrylicController.Kind != DesktopAcrylicKind.Thin || SystemBackdropConfiguration.Theme == prevTheme)
44+
var configuration = GetDefaultSystemBackdropConfiguration(target, xamlRoot);
45+
if (controller is not DesktopAcrylicController acrylicController || acrylicController.Kind != DesktopAcrylicKind.Thin || configuration.Theme == prevTheme)
4846
return;
4947

50-
prevTheme = SystemBackdropConfiguration.Theme;
51-
SetThinAcrylicBackdropProperties(acrylicController, SystemBackdropConfiguration.Theme);
48+
prevTheme = configuration.Theme;
49+
SetThinAcrylicBackdropProperties(acrylicController, configuration.Theme);
5250
}
5351

5452
protected override void OnTargetDisconnected(ICompositionSupportsSystemBackdrop disconnectedTarget)
@@ -81,9 +79,9 @@ private void OnSettingChanged(object? sender, SettingChangedEventArgs e)
8179
case nameof(IAppearanceSettingsService.AppThemeBackdropMaterial):
8280
controller?.RemoveAllSystemBackdropTargets();
8381
controller?.Dispose();
84-
SystemBackdropConfiguration = GetDefaultSystemBackdropConfiguration(target, root);
85-
var newController = GetSystemBackdropController((BackdropMaterialType)e.NewValue!, SystemBackdropConfiguration.Theme);
86-
newController?.SetSystemBackdropConfiguration(SystemBackdropConfiguration);
82+
var configuration = GetDefaultSystemBackdropConfiguration(target, root);
83+
var newController = GetSystemBackdropController((BackdropMaterialType)e.NewValue!, configuration.Theme);
84+
newController?.SetSystemBackdropConfiguration(configuration);
8785
newController?.AddSystemBackdropTarget(target);
8886
controller = newController;
8987
break;

0 commit comments

Comments
 (0)