[PR #4429] [CLOSED] Don't crash when the user tries to duplicate a tab with a profile that no longer exists #25753

Open
opened 2026-01-31 09:11:35 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/4429
Author: @zadjii-msft
Created: 1/31/2020
Status: Closed

Base: masterHead: dev/migrie/b/2455-with-new-tests


📝 Commits (10+)

  • a8bd503 I believe this is the bugfix
  • 648373d Try writing tests
  • 029b676 clean up these tests for PR
  • 0a6f72c Fix the tests o__o
  • 9849fe9 Merge remote-tracking branch 'origin/master' into dev/migrie/b/2455-with-new-tests
  • 963a830 Add the VERIFY_THROWS for dustin
  • 8ed39cd Merge branch 'master' into dev/migrie/b/2455-with-new-tests
  • 82ad8bb I think this will pull the settings from the control, but I haven't tested yet
  • eafe9c8 Wrap Application::Current in try/catch since that breaks tests
  • 908fd74 Try to clone the settings directly from the control

📊 Changes

6 files changed (+417 additions, -67 deletions)

View changed files

📝 src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp (+144 -0)
📝 src/cascadia/LocalTests_TerminalApp/TabTests.cpp (+136 -0)
📝 src/cascadia/TerminalApp/TerminalPage.cpp (+127 -64)
📝 src/cascadia/TerminalControl/TermControl.cpp (+5 -0)
📝 src/cascadia/TerminalControl/TermControl.h (+2 -0)
📝 src/cascadia/TerminalControl/TermControl.idl (+3 -3)

📄 Description

Summary of the Pull Request

When the user tries to duplicateTab with a profile that doesn't exist anymore (like might happen after a settings reload), don't crash.

PR Checklist

  • Closes Install without Windows Store (#2455)
  • I work here
  • Tests added/passed
  • [n/a] Requires documentation to be updated
  • Should we display an error dialog when this situation happens?
    • Should this be a follow-up task?

Detailed Description of the Pull Request / Additional comments

CascadiaSettings::BuildSettings can throw if the GUID doesn't exist. This wraps those calls up with a try/catch.

It also adds a couple tests - a few SettingsTests for try/catching this state. It also adds a XAML-y test in TabTests that creates a TerminalPage and then performs som UI-like actions on it. This test required a minor change to how we generate the new tab dropdown - in the tests, Application::Current() is not a TerminalApp::App, so it doesn't have a Logic() to query. So wrap that in a try/catch as well.

Validation Steps Performed

  • Ran tests - new tests pass!
  • Validated scenario manually

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/4429 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 1/31/2020 **Status:** ❌ Closed **Base:** `master` ← **Head:** `dev/migrie/b/2455-with-new-tests` --- ### 📝 Commits (10+) - [`a8bd503`](https://github.com/microsoft/terminal/commit/a8bd5036f0d85d9910e56afb86664b8bca9c0d4e) I believe this is the bugfix - [`648373d`](https://github.com/microsoft/terminal/commit/648373d05cb24aadd49d522f2348994bf0bbd248) Try writing tests - [`029b676`](https://github.com/microsoft/terminal/commit/029b67633718ca525e313fdca20729d5f1519f61) clean up these tests for PR - [`0a6f72c`](https://github.com/microsoft/terminal/commit/0a6f72c6dea793f8ea0f2c229f07e8af98ebf8c5) Fix the tests o__o - [`9849fe9`](https://github.com/microsoft/terminal/commit/9849fe9b638676bb41b04da1c292f4c4eadb5992) Merge remote-tracking branch 'origin/master' into dev/migrie/b/2455-with-new-tests - [`963a830`](https://github.com/microsoft/terminal/commit/963a83024142d5ebabcafef0e64115f23ce62631) Add the VERIFY_THROWS for dustin - [`8ed39cd`](https://github.com/microsoft/terminal/commit/8ed39cd4ce6e926d1d272b04efc4310a29f21b46) Merge branch 'master' into dev/migrie/b/2455-with-new-tests - [`82ad8bb`](https://github.com/microsoft/terminal/commit/82ad8bba3c62996af805256661aad617ede1f2b5) I _think_ this will pull the settings from the control, but I haven't tested yet - [`eafe9c8`](https://github.com/microsoft/terminal/commit/eafe9c8fbce329988d5708c8a80bad8be3d2b079) Wrap Application::Current in try/catch since that breaks tests - [`908fd74`](https://github.com/microsoft/terminal/commit/908fd74c6762dae3cf7d1b0b545c7a1ae01b5d4d) Try to clone the settings directly from the control ### 📊 Changes **6 files changed** (+417 additions, -67 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp` (+144 -0) 📝 `src/cascadia/LocalTests_TerminalApp/TabTests.cpp` (+136 -0) 📝 `src/cascadia/TerminalApp/TerminalPage.cpp` (+127 -64) 📝 `src/cascadia/TerminalControl/TermControl.cpp` (+5 -0) 📝 `src/cascadia/TerminalControl/TermControl.h` (+2 -0) 📝 `src/cascadia/TerminalControl/TermControl.idl` (+3 -3) </details> ### 📄 Description ## Summary of the Pull Request When the user tries to `duplicateTab` with a profile that doesn't exist anymore (like might happen after a settings reload), don't crash. ## PR Checklist * [x] Closes #2455 * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated * [ ] Should we display an error dialog when this situation happens? - Should this be a follow-up task? ## Detailed Description of the Pull Request / Additional comments `CascadiaSettings::BuildSettings` can throw if the GUID doesn't exist. This wraps those calls up with a try/catch. It also adds a couple tests - a few `SettingsTests` for try/catching this state. It also adds a XAML-y test in `TabTests` that creates a `TerminalPage` and then performs som UI-like actions on it. This test required a minor change to how we generate the new tab dropdown - in the tests, `Application::Current()` is _not_ a `TerminalApp::App`, so it doesn't have a `Logic()` to query. So wrap that in a try/catch as well. ## Validation Steps Performed * Ran tests - new tests pass! * Validated scenario manually --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:11:35 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#25753