mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-09-02 12:13:27 +02:00
## Summary Guard PowerToys' WinUI windows against an empty native window title, so the WinUI `TitleBar` control can't read an empty title during startup and fault the process. This fixes a class of bugs like https://github.com/microsoft/PowerToys/issues/48547 ## Background Spotted while reading through the Environment Variables `MainWindow` startup path. The WinUI `TitleBar` control (used with `ExtendsContentIntoTitleBar`) reads the owning window's `AppWindow.Title` during a deferred layout pass (`OnApplyTemplate` → `UpdateTitle`). When the native window title is empty at that instant, the windowing layer can fault while resolving the title and terminate the process during startup. The native title ends up empty in two ways: 1. The title is computed from `ResourceLoader.GetString(...)`, which returns an **empty string** (it doesn't throw) when the resource map can't be resolved at runtime. 2. The window sets `AppWindow.Title` only *later*, not before the title bar's first layout. ## Windows fixed Every PowerToys window that hosts the `TitleBar` control: | Window | Fix | |---|---| | Environment Variables | Non-empty fallback for the resource-based title | | Hosts | Non-empty fallback for the resource-based title | | File Locksmith | Non-empty fallback for the resource-based title | | Shortcut Guide | Non-empty fallback for the resource-based title | | Settings — shortcut-conflict window | Non-empty fallback for the resource-based title | | Registry Preview | Set `AppWindow.Title` to the app name in the constructor (previously only set later in `UpdateWindowTitle`) | | Keyboard Manager Editor | No change — already sets a hardcoded non-empty `Title` | ## Risk Very low. The only behavior change is that a previously-empty title becomes a non-empty fallback; the normal (resource-resolved) paths are unchanged. ## Validation Each affected project builds clean (`x64 | Release`): EnvironmentVariables, Hosts, FileLocksmithUI, ShortcutGuide.Ui, RegistryPreview, PowerToys.Settings. ## Related Root cause write-up (windowing/WinUI side): microsoft/microsoft-ui-xaml#11214. --- ADO: https://microsoft.visualstudio.com/DefaultCollection/OS/_workitems/edit/62685601/ --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>