Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fire and forget Hyperlink handling to break deadlock #8087

Merged
2 commits merged into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3012,10 +3012,20 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
// - Checks if the uri is valid and sends an event if so
// Arguments:
// - The uri
void TermControl::_HyperlinkHandler(const std::wstring_view uri)
winrt::fire_and_forget TermControl::_HyperlinkHandler(const std::wstring_view uri)
{
auto hyperlinkArgs = winrt::make_self<OpenHyperlinkEventArgs>(winrt::hstring{ uri });
_openHyperlinkHandlers(*this, *hyperlinkArgs);
// Save things we need to resume later.
winrt::hstring heldUri{ uri };
auto strongThis{ get_strong() };

// Pop the rest of this function to the tail of the UI thread
// Just in case someone was holding a lock when they called us and
// the handlers decide to do something that take another lock
// (like ShellExecute pumping our messaging thread...GH#7994)
co_await Dispatcher();

auto hyperlinkArgs = winrt::make_self<OpenHyperlinkEventArgs>(heldUri);
_openHyperlinkHandlers(*strongThis, *hyperlinkArgs);
}

// Method Description:
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalControl/TermControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
void _LostFocusHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e);
winrt::fire_and_forget _DragDropHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::DragEventArgs const e);
void _DragOverHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::DragEventArgs const& e);
void _HyperlinkHandler(const std::wstring_view uri);
winrt::fire_and_forget _HyperlinkHandler(const std::wstring_view uri);

void _CursorTimerTick(Windows::Foundation::IInspectable const& sender, Windows::Foundation::IInspectable const& e);
void _BlinkTimerTick(Windows::Foundation::IInspectable const& sender, Windows::Foundation::IInspectable const& e);
Expand Down