Skip to content

Commit

Permalink
bring out your dead
Browse files Browse the repository at this point in the history
  • Loading branch information
leonMSFT committed Jun 7, 2021
1 parent f82cffa commit 46af976
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
22 changes: 20 additions & 2 deletions src/cascadia/Remoting/Monarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,10 +766,28 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
Windows::Foundation::Collections::IMap<uint64_t, winrt::hstring> Monarch::GetPeasantNames()
{
auto names = winrt::single_threaded_map<uint64_t, winrt::hstring>();
for (auto [key, value] : _peasants)

std::vector<uint64_t> peasantsToErase{};
for (const auto& [id, p] : _peasants)
{
names.Insert(key, value.WindowName());
try
{
names.Insert(id, p.WindowName());
}
catch (...)
{
LOG_CAUGHT_EXCEPTION();
peasantsToErase.push_back(id);
}
}

// Remove the dead peasants we came across while iterating.
for (const auto& id : peasantsToErase)
{
_peasants.erase(id);
_clearOldMruEntries(id);
}

return names;
}
}
7 changes: 6 additions & 1 deletion src/cascadia/WindowsTerminal/AppHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ AppHost::AppHost() noexcept :
AppHost::~AppHost()
{
// destruction order is important for proper teardown here
if (_trayIconData)
{
Shell_NotifyIcon(NIM_DELETE, &_trayIconData.value());
_trayIconData.reset();
}

_window = nullptr;
_app.Close();
Expand Down Expand Up @@ -646,7 +651,6 @@ void AppHost::_BecomeMonarch(const winrt::Windows::Foundation::IInspectable& /*s
const winrt::Windows::Foundation::IInspectable& /*args*/)
{
_UpdateTrayIcon();
_CreateTrayContextMenu();
_setupGlobalHotkeys();

// The monarch is just going to be THE listener for inbound connections.
Expand Down Expand Up @@ -1027,6 +1031,7 @@ void AppHost::_ShowTrayContextMenu(const til::point coord)

HMENU AppHost::_CreateTrayContextMenu()
{
assert(_windowManager.IsMonarch());
auto hmenu = CreatePopupMenu();
if (hmenu)
{
Expand Down
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion src/cascadia/WindowsTerminal/WindowsTerminal.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,4 @@
</Target>
<Import Project="$(OpenConsoleDir)\build\rules\GenerateSxsManifestsFromWinmds.targets" />
<Import Project="..\..\..\packages\Microsoft.Internal.Windows.Terminal.ThemeHelpers.0.3.210521003\build\native\Microsoft.Internal.Windows.Terminal.ThemeHelpers.targets" Condition="Exists('..\..\..\packages\Microsoft.Internal.Windows.Terminal.ThemeHelpers.0.3.210521003\build\native\Microsoft.Internal.Windows.Terminal.ThemeHelpers.targets')" />
</Project>
</Project>

1 comment on commit 46af976

@github-actions

This comment was marked as resolved.

Please sign in to comment.