Skip to content

Commit

Permalink
Prevent a crash on resizing too small caused by the Titlebar (#2118)
Browse files Browse the repository at this point in the history
Only set the MaxWidth of the TitlebarControl's Content when the value is
  positive. Any smaller will crash the app.
  • Loading branch information
zadjii-msft authored Jul 26, 2019
1 parent 644ac56 commit dd1f8a8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/cascadia/TerminalApp/TitlebarControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,19 @@ namespace winrt::TerminalApp::implementation
ContentRoot().Children().Append(content);
}

void TitlebarControl::Root_SizeChanged(const IInspectable& sender, Windows::UI::Xaml::SizeChangedEventArgs const& e)
void TitlebarControl::Root_SizeChanged(const IInspectable& sender,
const Windows::UI::Xaml::SizeChangedEventArgs& e)
{
const auto windowWidth = ActualWidth();
const auto minMaxCloseWidth = MinMaxCloseControl().ActualWidth();
const auto dragBarMinWidth = DragBar().MinWidth();
const auto maxWidth = windowWidth - minMaxCloseWidth - dragBarMinWidth;
ContentRoot().MaxWidth(maxWidth);
// Only set our MaxWidth if it's greater than 0. Setting it to a
// negative value will cause a crash.
if (maxWidth >= 0)
{
ContentRoot().MaxWidth(maxWidth);
}
}

void TitlebarControl::_OnMaximizeOrRestore(byte flag)
Expand Down

0 comments on commit dd1f8a8

Please sign in to comment.