Skip to content

Commit dd1f8a8

Browse files
authored
Prevent a crash on resizing too small caused by the Titlebar (microsoft#2118)
Only set the MaxWidth of the TitlebarControl's Content when the value is positive. Any smaller will crash the app.
1 parent 644ac56 commit dd1f8a8

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/cascadia/TerminalApp/TitlebarControl.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,19 @@ namespace winrt::TerminalApp::implementation
3535
ContentRoot().Children().Append(content);
3636
}
3737

38-
void TitlebarControl::Root_SizeChanged(const IInspectable& sender, Windows::UI::Xaml::SizeChangedEventArgs const& e)
38+
void TitlebarControl::Root_SizeChanged(const IInspectable& sender,
39+
const Windows::UI::Xaml::SizeChangedEventArgs& e)
3940
{
4041
const auto windowWidth = ActualWidth();
4142
const auto minMaxCloseWidth = MinMaxCloseControl().ActualWidth();
4243
const auto dragBarMinWidth = DragBar().MinWidth();
4344
const auto maxWidth = windowWidth - minMaxCloseWidth - dragBarMinWidth;
44-
ContentRoot().MaxWidth(maxWidth);
45+
// Only set our MaxWidth if it's greater than 0. Setting it to a
46+
// negative value will cause a crash.
47+
if (maxWidth >= 0)
48+
{
49+
ContentRoot().MaxWidth(maxWidth);
50+
}
4551
}
4652

4753
void TitlebarControl::_OnMaximizeOrRestore(byte flag)

0 commit comments

Comments
 (0)