Clicking on a tab sometimes causes a crash #1188
Labels
Area-User Interface
Issues pertaining to the user interface of the Console or Terminal
Issue-Bug
It either shouldn't be doing this or needs an investigation.
Needs-Tag-Fix
Doesn't match tag requirements
Product-Terminal
The new Windows Terminal.
Severity-Crash
Crashes are real bad news.
Milestone
Environment
I don't think it matters; commit 2da5b0b
Steps to reproduce
Add some tabs, close some tabs. Might have to fiddle about with focus or something. It doesn't always happen straight away.
Expected behavior
It doesn't crash.
Actual behavior
It crashes, losing all your tabs.
The crash is here, on line 93 of Microsoft.Terminal.TerminalControl.h in Title():
check_hresult(WINRT_SHIM(Microsoft::Terminal::TerminalControl::ITermControl)->get_Title(&value));
The calling code is at line 1037..1041 of App.cpp in GetTitle():
And the caller of that was _OnTabSelectionChanged().
Unfortunately it is not a thrown exception but an access violation, so the C++ exception handling doesn't help.
Inside _GetFocusedControl(), it would be possible for _GetFocusedTabIndex() to return -1, but it doesn't seem to be in this case. Also it could conceivably return >= _tabs.size() but it isn't doing that either. The problem is that _GetFocusedTerminalControl() returns nullptr, which according to its documentation is a reasonable thing to do.
I changed the code inside the try{} to:
This seems to stop it crashing. But there are other places where _GetFocusedControl() is called without checking for a null result. So perhaps another tab should be considered focused, or something.
Also if you create shells quickly, some of them end up with no title. I think that's related, because if you click on one of those tabs, the window title (can be seen by hovering over the app's icon in the taskbar) is "Windows Terminal" which is GetTitle()s default.
The text was updated successfully, but these errors were encountered: