Skip to content

Commit 20e5e5c

Browse files
authored
Code Quality: Handle COMException in ShellPanesPage (#15935)
1 parent 02ea129 commit 20e5e5c

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/Files.App/Views/ShellPanesPage.xaml.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,24 @@ public ShellPanesPage()
246246

247247
// Set default values
248248
ActivePane = GetPane(0);
249-
_WindowIsCompact = MainWindow.Instance.Bounds.Width <= Constants.UI.MultiplePaneWidthThreshold;
249+
250+
try
251+
{
252+
_WindowIsCompact = MainWindow.Instance.Bounds.Width <= Constants.UI.MultiplePaneWidthThreshold;
253+
MainWindow.Instance.SizeChanged += MainWindow_SizeChanged;
254+
}
255+
catch (Exception)
256+
{
257+
// Handle exception in case WinUI Windows is closed
258+
// (see https://github.com/files-community/Files/issues/15599)
259+
260+
_WindowIsCompact = false;
261+
}
250262

251263
// Open the secondary pane
252264
if (IsMultiPaneAvailable &&
253265
GeneralSettingsService.AlwaysOpenDualPaneInNewTab)
254266
AddPane();
255-
256-
MainWindow.Instance.SizeChanged += MainWindow_SizeChanged;
257267
}
258268

259269
// Public methods

0 commit comments

Comments
 (0)