From 882bf56961d5f277ba23becdd7a4a66c626a4270 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Fri, 28 Apr 2023 10:17:57 -0500 Subject: [PATCH] Don't explode when we tear out the last tab of the window If you were really fast, and closed one window, and then tried to drag the only tab out of the last remaining window, the Terminal could explode. It'd attempt to restore the previous window state, and explode. Easy way to stop this (also, be more robust): just don't attempt to restore windows during tear-out. That's obvious. This is a part of #14957 --- src/cascadia/WindowsTerminal/AppHost.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cascadia/WindowsTerminal/AppHost.cpp b/src/cascadia/WindowsTerminal/AppHost.cpp index eaecfd731e1..163d056df88 100644 --- a/src/cascadia/WindowsTerminal/AppHost.cpp +++ b/src/cascadia/WindowsTerminal/AppHost.cpp @@ -168,8 +168,8 @@ void AppHost::_HandleCommandlineArgs(const Remoting::WindowRequestedArgs& window if (_peasant) { const auto& args{ _peasant.InitialArgs() }; - - if (!windowArgs.Content().empty()) + const bool startedForContent = !windowArgs.Content().empty(); + if (startedForContent) { _windowLogic.SetStartupContent(windowArgs.Content(), windowArgs.InitialBounds()); } @@ -220,7 +220,8 @@ void AppHost::_HandleCommandlineArgs(const Remoting::WindowRequestedArgs& window // seemed to reorder bits of init so much that everything broke. So // we'll leave it here. const auto numPeasants = _windowManager.GetNumberOfPeasants(); - if (numPeasants == 1) + // Don't attempt to session restore if we're just making a window for tear-out + if (!startedForContent && numPeasants == 1) { const auto layouts = ApplicationState::SharedInstance().PersistedWindowLayouts(); if (_appLogic.ShouldUsePersistedLayout() &&